Armstrong

// Enter a no & check if it is armstrong or not
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,s=0;
clrscr();
printf("\n Enter a no:-");
scanf("%d",&n);
b=n;
while(n>0)
{
a=n%10;
s=s+(a*a*a);
n=n/10;
}
if(s==b)
{
printf("\n No. is armstrong");
}
else
{
printf("\n No. is not armstrong");
}
getch();
}

No comments:

Post a Comment