Programming Examples

Algorithm to accept a number and check whether the given number is an Armstrong number


Write an algorithm to accept a number and check whether the given number is an Armstrong number.  A number is called an Armstrong number if the sum of the cubes of its digits is same as the number. 

1.	Accept the value of n.
2.   Set temp=n, arm=0, rem=0.
3.   Repeat the steps, a, b, and c, until n>0.
a. Set rem=n%10.
b. Set arm=arm+(rem*rem*rem).
c. Set n=n/10.
4.	If temp=arm, then:
Display “It is an Armstrong number.” 
5.	Else:
Display “It is not an Armstrong number.”
Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz