C : Program to check given number is armstrong or not.
Code:
#include<stdio.h>
#include<conio.h>
main()
{
int n,x;
printf("Enter a number:");
scanf("%d",&n);
x=armstrong(n);
if(x==n)
printf("Arm strong");
else
printf("Not arm strong");
}
int armstrong(int num)
{
int sum=0,r;
while(num!=0)
{
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
return sum;
}
Output:
Enter a number:1
Arm strong
Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...
-
Input the date of birth of a person and find his age in terms of year, month and days. using class. Age Calculator of a Person Co...
-
In our previous tutorial we have discussed all about Inheritance. What is it? Why it is required? and its different types! Moreover, we ...
-
Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...