Program Description:

In this program we are going to check whether the number entered by the user is an Armstrong number or not. Armstrong number are those numbers whose if do the cube of each digit and add them the sum is the same number. For example, 153- If we do the cube of 1(=1) , 5(=125), 3(=27) and add then the sum will be equal to 153. Other examples of Armstrong number are 0,370,371 etc.

Source Code:

#include<stdio.h>
int main()
{
int n,i,sum=0,r;
printf("Enter a number:");
scanf("%d",&n);
i=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(sum==i)
printf("%d is an armstrong number",i);
else
printf("%d is not a armstrong number",i);
}

Output:



If you have any queries regarding the program then feel free to ask us in the comments section below!!