Program to Display Armstrong Number Between Two Intervals - (C Programs)
Example
In this program, the user is asked to enter two intervals. The program then displays all the Armstrong numbers in that range.
Enter two intervals: 100 400
Armstrong numbers between 100 and 400 are:
153 370 371
Explanation
Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.
In this program, we ask the user to enter two intervals. We then loop through all the numbers in that range and check if they are Armstrong numbers or not. If a number is an Armstrong number, we display it.
To check if a number is an Armstrong number, we first calculate the number of digits in that number. We then loop through all the digits of that number and add up each digit raised to the power of the number of digits. If the sum is equal to the original number, then it is an Armstrong number.
Output
If the user enters the range from 100 to 400, the output will be:
Enter two intervals: 100 400
Armstrong numbers between 100 and 400 are:
153 370 371
Use
This program can be used to find all the Armstrong numbers between any two intervals provided by the user. This can be helpful in various mathematical and scientific applications.
Summary
This program asks the user to enter two intervals. It then finds and displays all the Armstrong numbers in that range. Armstrong numbers are numbers that are equal to the sum of its own digits raised to the power of the number of digits. This program can be useful in various mathematical and scientific applications.