WHAT IS ARMSTRONG NUMBER?
Sum of a number’s digits raised to the power total number of digits is armstrong number
Armstrong numbers example: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634 etc
Explanation:
3 = 3^1 = 3
153 = 1^3 + 5^3 + 3^3 = 153
vim armstrongnumber.c
#include <stdio.h>
int main()
{
int n, sum, remainder;
printf("Please enter a number to find whether it is an armstrong or not: ");
scanf("%d", &n);
int temp = n;
sum = 0;
while(temp != 0)
{
remainder = temp % 10;
sum += remainder * remainder * remainder;
temp = temp / 10;
}
if (n == sum)
{
printf("%d is a armstrong number\n", n);
}
else
{
printf("%d is not a armstrong nubmer\n", n);
}
}