/* Armstrong Number : Armstrong number is a number that is equal to the sum of cubes of its digits. */
#include <stdio.h>
int main()
{
int num, temp, arm = 0;
printf("Enter a number you want to check armstrong or not: ");
scanf("%d", &num);
temp = num;
printf("Number is %d.\n", num);
while (num > 0){
arm += (num%10)*(num%10)*(num%10) ;
num = num/10;
}
printf("Sum of cubes of digits: %d\n", arm);
if(arm == temp)
printf("%d is a Armstrong number.", temp);
else
printf("%d is not an Armstrong number.", temp);
return 0;
}
Comments
Post a Comment