Latest

# Whether a Given Number is Armstrong Number – C Program

### Armstrong Number

“Armstrong number is a number which is equal to sum of digits raise to the power total number of digits in the number.”
Example:
“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. Write a program to find all Armstrong number in the range of 0 and 999.”

### Source Code

```#include <stdio.h>
#include <conio.h>
#include <math.h>

//Armstrong Number - FScOnline.info

int main()
{
int num, sum=0, digit, temp;

printf("Enter 3 Digits Numnber: ");
scanf("%d", &num);

if(num < 99 || num > 999)
printf("\nPlease enter 3 digit number only....");
else
{
temp=num;

while(num!=0)
{
digit=num%10;
sum+=pow(digit,3);
num=num/10;
}

if(temp==sum)
printf("\n%d is an Armstrong Number", temp);
else
printf("\n%d is not an Armstrong Number", temp);
}

getch();
return 0;
}```

### Output

Categories: C Language,C Programs,Computer Science

×