// C Program to Check Armstrong Number using While loop
int main() {
int x, y, z, rem, n = 0;
float r = 0.0;
// x - To store the input number
// y & z - To store the storage of original input number to check
// rem - To store the reminder
// r - To store the result variable
printf("-----Enter the integer number-----\n");
scanf("%d", &x);
z = y = x;
while (y != 0) {
y /= 10;
++n;
}
while (z != 0) {
rem = z % 10;
r += pow(rem, n);
z /= 10;
}
// if x is equal to r, the number is an Armstrong number
if ((int) r == x) {
printf("%d is an Armstrong number.\n", x);
} else {
printf("%d is not an Armstrong number.\n", x);
}
return 0;
}