C++ Program to Check given number either Armstrong Number or not.
#include <iostream.h>
int main()
{
int origNum, num, rem, sum = 0;
cout << "Enter a positive integer: ";
cin >> origNum;
num = origNum;
while(num != 0)
{
digit = num % 10;
sum += digit * digit * digit;
num /= 10;
}
if(sum == origNum)
cout << origNum << " is an Armstrong number.";
else
cout << origNum << " is not an Armstrong number.";
return 0;
}
Output
Enter a positive integer: 371371 is an Armstrong number.
Tags:
armstrong number
C++ Program to Check given number either Armstrong Number or not.
manjeet singh kuthar
mskuthar
what is armstrong number