counter

Free Hit Counter

C program to print armstrong numbers


Q:A program to print Armstrong numbers between 1 to 500

#include
#include
#include
void main ()
{
int i=1,a,b,c;
clrscr();
while(i<=500)
{

a=i%10;
b=i%100;
b=(b-a)/10;
c=i/100;
if(a*a*a+b*b*b+c*c*c==i)
{
printf("armstrong no.:%d\n",i);
}
i++;
}
getch();
}

No comments:

Post a Comment