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();
}
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();
}
yess it worksss!!!!
ReplyDeleteYu have used clrscr() and getch() which is included in
ReplyDeleteVery informative article.Thank you author for posting this kind of article .
ReplyDeletehttp://www.wikitechy.com/view-article/c-program-to-check-armstrong-number-with-example-and-explanation
Both are really good,
Cheers,
Venkat