In this program we will use while loop to check whether given number is Armstrong number or not. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371
Code for C program to check whether the given number is an Armstrong number
#include <stdio.h>
#include <conio.h>
int main()
{
int num, remainder, total = 0, temp;
printf("Enter the number=");
scanf("%d", &num);
temp = num;
while (num > 0)
{
remainder = num % 10;
total = total + (remainder * remainder * remainder);
num = num / 10;
}
if (temp == total)
printf("This number is Armstrong number");
else
printf("This number is not Armstrong number");
return 0;
}
Output
Enter the number=371
This number is Armstrong number
Enter the number=53
This number is not Armstrong number