Important Questions

C++ Program to Check Armstrong Number

//C++ Program to Check Armstrong Number
//header files
#include<iostream.h>
#include<conio.h>

void main()
{

clrscr();
int origNum, num, rem, sum = 0;
cout << "Enter a positive integer: ";
cin >> origNum;
num = origNum;
while(num != 0)
{

rem = num % 10;
sum += rem * rem * rem;
num /= 10;

}
if(sum == origNum)
{

cout << origNum << " is an Armstrong number.";

}
else
{

cout << origNum << " is not an Armstrong number.";

}
getch();

}

Output


You can also see a video how to run this program