PRACTICAL- 7
Aim of the
practical:-
Write a program (WAP) to enter any number and check
that whether it is an Armstrong number or not.
Header files used:-
#include
<iostream.h>
#include
<stdlib.h>
#include
<math.h>
Conditional statements/Loops used:-
i.
If– else statement
ii.
while loop
Armstrong Number:-
A positive
number is called an Armstrong number if the number formed by the sum of the
cubes of indevidual digits of that number is the number itself.
For
example:- 0,1,153,370,371 and 407
153=1*1*1+5*5*5+3*3*3
Procedures followed:-
The
user will be asked to enter any number. We need to store a duplicate copy of
that number in another variable. Then the each digit of the number will be
added after finding its cube and stored in another variable. After this the
number formed will be compared with the duplicate copy stored earlier to check
whether it is an Armstrong number or not.
Coding:-
No comments:
Post a Comment