ambrasant number like 153=1^3+5^3+3^3=153
# include <stdio.h>
# include <conio.h>
# include <math.h>
void main ()
{
int a[200],t,i=0,j=0,b=0,sum=0;
long int n;
clrscr();
printf("Enter the NO. upto : ");
scanf("%ld",&n);
for(j=0;j <n;j++)
{
t=j;
while(0 <t)
/*counts the digits*/
{
i=0;
a[i]=j%10;
t=t/10;
b++;
i++;
}
for(i=0;i <b;i++)
{
sum=+pow(a[i],3);
}
if(sum==n)
{
printf("\n%d AN ARMSTRONG NUMBER...",j);
}
else
{
printf("\n%d IS NOT AN ARMSTRONG NUMBER...",j);
}
}
getch();
}
No comments:
Post a Comment