- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
To check whether any positive number is an Armstrong number or not, following is the example: Since 153 is equal to 1^3 + 5^3 + 3^3. So 153 is an Armstrong number Since 12 is not equal to 1^3 + 2^3. So 12 is not an Armstrong number
Source Code:Check if a given number is Armstrong or Not
/* C++ Program - Check Armstrong or Not */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int n, nu, num=0, rem; cout<<"Enter any positive number : "; cin>>n; nu=n; while(nu!=0) { rem=nu%10; num=num + rem*rem*rem; nu=nu/10; } if(num==n) { cout<<"Armstrong Number"; } else { cout<<"Not Armstrong Number"; } getch(); }Output
Enter any positive number : 153 Armstrong Number