#include<stdio.h>
int main () {
int num,n,sum,r,limit;
printf("ENTER THE LIMIT\n");
scanf("%d",&limit);
printf("Armstrong numbers upto given limit are:\n");
for(num=1;num<limit;num++)
{
n = num;
sum = 0 ;
while (n!=0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(sum==num)
{printf("%7d\n",num);}
}
return 0;
}
Have a Read!
Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!
Saturday, January 29, 2011
Subscribe to:
Post Comments (Atom)
The above code isn't working for limit more than 1000 .... Can you give any other solution for this???
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteArmstrong program in C
ReplyDeletesimple