Thursday, July 28, 2011

Armstrong Number

#include<stdio.h>

#include<math.h>

void main()
{
int num,dup,rem,sum=0;
clrscr();
printf("Enter a number : ");
scanf("%d",&num);
dup=num;
while(num>0)
{
rem=num%10;
sum+=pow(rem,3);
num/=10;
}
if(dup==sum)
 printf("\nIt is an Amstrong number");
else
 printf("Not an Amstrong number");
getch();
}

No comments:

Post a Comment