To check whethwe number is armstrong or not

#include<stdio.h>
main()
{
int n,tot=0,tmp,d;
clrscr();
printf("\n enter the number");
scanf("%d",&n);
tmp=n;
while(n>0)
{
d=n%10;
tot=(d*d*d)+tot;
n=n/10;
}
if(tmp==tot)
printf("\n enter number is armstrong");
else
printf("enter number is not armstrong");
getch();
}

Comments

Post a Comment