Write a c++ program to print Armstrong number for three digits

Write a c++ program to print Armstrong number for three digits. This program will help you to find the Armstrong number in C++. These are basic set program in every programming lanuguage for beginners.

#include <iostream>
using namespace std;
int main() 
{
int num, num1, rem, result = 0;
cout << "Enter the number";
cin >> num;
num1 = num;
while (num1 != 0)
{
rem = num1 % 10;
result += rem * rem * rem;
num1 /= 10;
}
if (result == num)
cout << num << " is Armstrong number";
else
cout << num << " is not Armstrong number";
return 0;
}

Output:

Enter the number567

567 is not Armstrong number

What is armstrong and why it is called armstrong number in c++ program

A number equal to the sum of its digits’ cubes is known as an Armstrong number. An Armstrong three-digit number is an integer in which the total of its digits’ cubes equals the number itself. 371 is an Armstrong number, for example, since 3**3 + 7**3 + 1**3 Equals 371.