Friday, September 12, 2008

ARMSTRONG NUMBER in c programming language


void main()
{
int num,r,sum=0,temp;
clrscr();
printf("\nEnter a number:-");
scanf("%d",&num);
temp=num;
while(num!=0)
{
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("\nThe number %d is an armstrong number",temp);
else
printf("\nThe number %d is not an armstrong number",temp);
getch();

No comments:

Post a Comment

Thanks to given comments.......

My Blog List