24 December 2011

Write a Program to Find Armstrong Number

Leave a Comment


Program to Find Armstrong Number Between 1 to 500 (in c)


how to find Armstrong number


Here is c program to find armstrong number


#include<stdio.h>
void main()
{
int a,b,c,d,i;
printf("The armstrong number between 1 to 500 are : ");
i = 1;
//loop till 500
while(i<=500)
{
c=i;
d =i;
b = 0;
a = 0;
//checking each number
while(c>0)
{
a = c%10;
b +=a*a*a;
c = c/10;
}
if(b==d)
printf("\n%d",i);
i++;
}
}

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

0 comments:

Post a Comment