C Program to check a number is Armstrong or not
In this program, You will learn how to check a number is Armstrong or not in c.
Some list of Armstrong numbers is : 153, 370, 371, 407
Example: How to check a number is Armstrong or not in c.
#include<stdio.h>
int main() {
int x, y, r, arm = 0;
printf("Enter a number:");
scanf("%d", &x);
y = x;
while (x > 0) {
r = x % 10;
arm = arm + r * r * r;
x = x / 10;
}
if (y == arm) {
printf("Number is Armstrong:%d", y);
} else {
printf("Number is not Armstrong:%d", y);
}
return 0;
}
Output:
Enter a number:153
Number is Armstrong:153