#include<stdio.h>
#include<math.h>
void main()
{
int num,sum,lim,dig,temp;
clrscr();
printf("Enter the limit :");
scanf("%d",&lim);
printf("\nArmstrong num upto %d are :\n",lim);
for(num=1;num<=lim;++num)
{
for(temp=num,sum=0;temp>0;temp/=10)
{
dig=temp%10;
sum+=pow(dig,3);
}
if(num==sum)
printf("%d\n",num);
}
getch();
}
#include<math.h>
void main()
{
int num,sum,lim,dig,temp;
clrscr();
printf("Enter the limit :");
scanf("%d",&lim);
printf("\nArmstrong num upto %d are :\n",lim);
for(num=1;num<=lim;++num)
{
for(temp=num,sum=0;temp>0;temp/=10)
{
dig=temp%10;
sum+=pow(dig,3);
}
if(num==sum)
printf("%d\n",num);
}
getch();
}
0 comments:
Post a Comment