C program to check whether a given number is an Armstrong number or not.
Language Used: C
What is an Armstrong Number:
When the sum of the cube of the individual digits of a number is equal to that number, the number is called Armstrong number.
For Example 153 is an Armstrong number because 153 = 13+53+33.
Concepts Involved:
For Loop
Syntax:
for (Statement; testExpression; updateStatement)
{
// statements
}
Flowchart:
C if_else Statement
Syntax:
if (test expression) {
// run code if test expression is true
}
else {
// run code if test expression is false
}
How it works?
Script:
Output:
Input a number: 73
73 is not an Armstrong number.
Description:
Here Void main function is used so no return statement is required.
printf function is used and the input from the user is read using the scanf statement and is stored in the variable num.
For loop is used and the corresponding statements are iterated if the conditions are satisfied.
If the sum value is equal to the temp value, the statements under if statement is performed and otherwise, else statement is executed.
Flowchart:
For any Educational Assistance,
Refer: https://www.guvi.in/