//C Program to Check whether a given Number is Armstrong
#include <math.h>
#include <stdio.h>
int main() {
int rem,
sum = 0,
cube,
temp,
num,
i;
printf("Enter a number to check Armstrong: ");
scanf("%d", &num);
temp = num;
while (num != 0) {
rem = num % 10; // 153 to rem = 3 (last digit)
cube = pow(rem, 3); //3**3
sum = sum + cube; // 0 + 27
num = num / 10;
}
if (sum == temp) {
printf("\nThis number is Armstrong number.\n");
}
else {
printf("\nThis number is not Armstrong number.\n");
}
return 0;
}