#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int num,snum,sum,digit;
clrscr();
printf("\n\n Enter a number to test : ");
scanf("%d",&num);
snum = num;
sum = 0;
while(num>0)
{
digit = num % 10;
sum = sum + pow(digit,3);
num = num / 10;
}
if( snum == sum)
printf("\n\n The given number %d is an ARMSTRONG NUMBER\n\n",snum);
else
printf("\n\n The given number %d is not an ARMSTRONG NUMBER\n\n",snum);
return 0;
}
No comments:
Post a Comment