C Program to Generate ArmStrong Numbers

Generating Armstrong Numbers in C Program with Example code

By Using this program you can generate Armstrong number with the given limit. By using the input from user (user can specify the limit) we can generate Armstrong Number using Loop from one to the entered number and check and the each incremented value in the loop will performed to check whether Armstrong number or not. If it is an Armstrong number then it will be printed else it will not be printed. As we know Armstrong number is one if the sum of cubes of individual digits of a number is equal to the number itself. For example 371 is an armstrong number as
33 + 73 + 13 = 371
Some of the Armstrong number are 1, 153, 370, 407.


int main()
int r;
long int num = 0, i, sum = 0, temp;
printf("Enter the maximum limit to generate Armstrong number ");
printf("Following armstrong numbers are found from 1 to %ld
for( i = 1 ; i <= num ; i++ )
temp = i;
while( temp != 0 )
r = temp%10;
sum = sum + r*r*r;
temp = temp/10;
if ( i == sum )
sum = 0;
return 0;

Related Topic Top PPC Advertising Program Ad Networks List
Fibonacci Program in C Language
C Program Prime Number
C Program for Armstrong Number
Prime Number Program in Java

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback