Write a program to check number is Armstrong or not

#include<stdio.h>
#include<conio.h>
int main()
{
int no,sum,a,b;
sum=0;
printf("enter the number");
scanf("%d",&no);
b=no;
while(no!=0)
{
a=no%10;
sum=sum+(a*a*a);
no=no/10;
}
if(sum==b)
printf("no is armstrong");
else
printf("no is not armstrong");
}

No comments:

Post a Comment