Here is source code of the C Program to check whether a given number is armstrong number.
The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Check whether a given Number is Armstrong
int number, sum = 0, rem = 0, cube = 0, temp;
printf ("enter a number");
temp = number;
while (number != 0)
rem = number % 10;
cube = pow(rem, 3);
sum = sum + cube;
number = number / 10;
if (sum == temp)
printf ("The given no is armstrong no");
printf ("The given no is not a armstrong no");
Output: $ cc pgm41.c -lm $ a.out enter a number370 The given no is armstrong no $ a.out enter a number1500 The given no is not a armstrong no
Sanfoundry Global Education & Learning Series – 1000 C Programs.