This a C program to check whether a given number is armstrong or not .
Generally a number is said to be an armstrong number if the cubes of the digits is equal to its original number .
For Example : 153 is an armstrong number as 1³ + 5³ + 3³ = 153 whereas 234 is not an armstrong number as 2³+ 3³+ 4³ is not equal to 234.
PROGRAM :
Generally a number is said to be an armstrong number if the cubes of the digits is equal to its original number .
For Example : 153 is an armstrong number as 1³ + 5³ + 3³ = 153 whereas 234 is not an armstrong number as 2³+ 3³+ 4³ is not equal to 234.
PROGRAM :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int number,num,sum=0,remainder;
printf("Enter any number :\t");
scanf("%d",&number);
num=number;
while(num)
{
remainder=num%10;
sum=sum+remainder*remainder*remainder;
num=num/10;
}
if(number == sum)
printf("%d is an Armstrong number",number);
else
printf("%d is an not an Armstrong number",number);
return 0;
}
OUTPUT :| C - Armstrong number or not |