C program to print the Armstrong number for three digits of a given

C program to print the Armstrong number for three digits of a given. This program will help you to find the number is Armstrong number or not in C. Here is the program to check whether the number is an Armstrong number or not an Armstrong number. An Armstrong three-digit number is an integer in which the total of its digits’ cubes equals the number itself. 371 is an Armstrong number, for example, since 3**3 + 7**3 + 1**3 Equals 371.

#include <stdio.h>
int main() 
{
int num, a, rem, result = 0;
printf("Enter the number ");
scanf("%d", &num);
a = num;
while (a != 0) 
{
rem = a % 10;
result += rem * rem * rem;
a /= 10;
}
if (result == num)
printf("%d is an Armstrong number.", num);
else
printf("%d is not an Armstrong number.", num);
return 0;
}

 

Output

Enter a three-digit integer:

456

456 is not an Armstrong number