Friday , 15 November 2019
Home » Tutorials » C programming » Simple C program to find whether a number is an armstrong number or not

# Simple C program to find whether a number is an 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.

Algorithm: Step 1: Start
Step 3: Rem=n
Step 4: sum=0
Step 5: If n != 0,
rem=n%0
sum=sum+(rem*rem*rem)
Step 6: n=n/10, goto 5
Step 7: If n=0, then if temp=arm, print Number is armstrong
Step 8: if temp is not equal to arm print Number is not armstrong
Step 9: Stop

Program :

```#include
int main()
{
int number, sum = 0, n, rem;
printf("Enter a number\n");
scanf("%d",&number);
n = number;

while( n != 0 )
{
rem = n%10;
sum = sum + rem*rem*rem;
n = n/10;
}

if ( number == sum )
printf("Entered number is an armstrong number.");
else
printf("Entered number is not an armstrong number.");

return 0;
}``` 