Definition of an Armstrong number
Armstrong number is a number in which sum of its digits to power of number of its digits is equal to that number are known as Armstrong numbers.
Example: let the Number is 153
Total digits in 153 is 3
And 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
Armstrong Number in C, C Program for Amstrong Number upto a limit:
Armstrong number is a number in which sum of its digits to power of number of its digits is equal to that number are known as Armstrong numbers.
Example: let the Number is 153
Total digits in 153 is 3
And 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
Armstrong Number in C, C Program for Amstrong Number upto a limit:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,rem,sum,temp;
clrscr();
for(num=1;num<=500;num++)
{
temp=num;
sum
= 0;
while(temp!=0)
{
rem=temp%10;
temp=temp/10;
sum=sum+(rem*rem*rem);
}
if(sum==num)
printf("%d
",num);
}
getch();
}
/*
Output:
1 153 370 371 407
*/