# C Program to check whether a number is Armstrong or not.

## C Program to check whether a number is Armstrong or not

Given a number , write a program to check that given number is Armstrong or not . So for that first we have to know that what is Armstrong number .

What is Armstrong number:-  Click here

Sample input
`153`
Sample output
`Armstrong number `

## C Program to check whether a number is Armstrong or not

The objective of the code is to check whether a number is Armstrong or not .

Code(C):-

#include<stdio.h>
#include<conio.h>
int main()
{
int n,n1,n2,r,s=1,sum=0; //r=reminder
printf("Enter a number");
scanf("%d",&n);
n1=n;
n2=n;
while(n!=0)
{
r=n%10;
n=n/10;
while(n1!=0)
{
s=s*r;
n1=n1/10;
}
sum=sum+s;
s=1;
n1=n2;
}
if(sum==n2)
printf("number is Armstrong");
else
printf("number is not Armstrong");
return 0;
}
Output:-

Enter a number
153
number is Armstrong

### 4 Comments

1. It helps me thanks

2. thanks sir for this help

3. ðŸ‘ŒðŸ‘ŒðŸ‘ŒðŸ‘Œ

4. It's very helpfully thnkuu sir