Here is the program to calculate the Armstrong numbers, which will fall within the limit, starting from zero. The program expects the user to enter the upper limit.
Definition : Armstrong numbers are the integer numbers , where -the sum of third power of each digits – equals to the given number itself.
Logic : Here we traced the upper limit through a for loop, where in each of the iterations, we are checking if the sum of cubes of its digits equals that integer. If so, displaying the number.
The while loop is used to slice up a number, which, with a slight modification, can also help us in many other math related program segments. It needs to include the header “math.h”.
Program to find the armstrong numbers below a given number
printf(“\n\n\t ENTER THE UPPER LIMIT…: “);
printf(“\n\n\t ARMSTRONG NUMBERS ARE…: “);
sum = 0;
num = n;
dig = num%10;
sum = sum+pow(dig,3);
num = num/10;
if(sum == n)
Leave a Reply