Find whether given no is an Amstrong no?
#include < stdio.h>
#include < conio.h>
main()
{
int i,j,a,k=0;
clrscr();
printf("\n enter the no:");
scanf("%d",&i);
a=i;
while(i!=0)
{
j=i%10;
k=k+(j*j*j);
i=i/10;
}
if(k==a)
printf("amstrong no");
else
printf("not an amstrong no");
getch();
}
0 comments:
Post a Comment