Check if input is Armstrong number - C++ Program

Q. Write a C++ program to check the given number is Armstrong number or not.

Answer:

If the sum of cubes of individual digit is equal to that number itself, it is called Armstrong number.  For example:

153 = 1 * 1 * 1 + 5 * 5 * 5 + 3 * 3 * 3
       = 1 + 125 + 27
       = 153

153 is an Armstrong number, where 123 is not an Armstrong number.

123 = 1 * 1 * 1 + 2 * 2 * 2 + 3 * 3 * 3
       = 1 + 8 + 27
       = 36

#include<iostream>
using namespace std;
int main()
{
        int n, nu, num=0, rem;

        cout<<"\n 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<<"\n Number is Armstrong";
        }
        else
        {
                cout<<"\n Number is Not Armstrong";
        }
        return 0;
}


Output:

armstrong no