Exp 4 Armstrong Number
Exp 4 Armstrong Number
Batch: B1 Rollno: 15
Experiment 4
Aim: Write a C program to find the whether the number is an AMSTRONG number or not.
Theory:
An Armstrong number, also known as a narcissistic number, is defined as a number that is equal
to the sum of its own digits each raised to the power of the number of digits in that number.
For example, the number 153 is an Armstrong number because:
13 + 53 + 33 = 1 + 125 + 27 = 153
Since, Sum = Number
Algorithm:
1. Start
2. Input an integer in variable n
3. insert value of n into num
4. Using while loop
A. while "n" is not equal to zero
B. Using modulus operator to extract each digit from number and storing it in
variable rem
C. By arithmetic operation, finding sum by using rem raised to the power 3
D. The digit is then removed from n by performing integer division by 10.
E. Go to step A
5. If num = sum
• Display "Given number is armstrong "
Else
• Display "Given number is not armstrong"
6. Stop
Flowchart:
Code:
Output:
Conclusion:
In conclusion, the C program for checking Armstrong numbers effectively illustrates
fundamental programming concepts such as loops, conditionals, and mathematical calculations.
By following a structured algorithm, it accurately determines whether a given integer meets the
criteria of an Armstrong number.