C++ Programming Code Examples C++ > Mathematics Code Examples Armstrong Number Program in C++ Armstrong Number Program in C++ Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits is equal to the number itself. Some Armstrong numbers is 0, 1, 153, 370, 371, 407, 1634 etc. For example: Three Digits Armstrong number is 153, 1 ^ 3 + 5 ^ 3 + 3 ^ 3 = 153 Four Digits Armstrong number is 1634, 1 ^ 4 + 6 ^ 4 + 3 ^ 4 + 4 ^ 4 + = 1634 153 = (1*1*1)+(5*5*5)+(3*3*3) where: (1*1*1)=1 (5*5*5)=125 (3*3*3)=27 So: 1+125+27=153 371 = (3*3*3)+(7*7*7)+(1*1*1) where: (3*3*3)=27 (7*7*7)=343 (1*1*1)=1 So: 27+343+1=371 #include<iostream.h> #include<conio.h> void main() { int arm=0,a,b,c,d,no; clrscr(); cout<<"Enter any num: "; cin>>no; d=no; while(no>0) { a=no%10; no=no/10; arm=arm+a*a*a; } if(arm==d) { cout<<"Armstrong"; } else { cout<<"not Armstrong"; } getch(); }