Program to Find Armstrong Number C++

Here we write a program to find whether the given number is Armstrong number C++ or not.

First let’s start understand what is Armstrong number also known as Narcissistic number ?

What is Armstrong number:

A number is Armstrong if the sum of cubes of individual digits of a number is equal to the number itself.

Example: 371 is an Armstrong number.

371 = (3*3*3)+(7*7*7)+(1*1*1)  

Some other Armstrong numbers are: 0, 1, 153, 370, 407.

Now lets write the program for the same.

Program to check whether the number is Armstrong number C++:

#include <iostream>
using namespace std;

int main()
   int number, sum = 0, temp, remainder;

   cout<<"Enter an integern;

   temp = number;

   while( temp != 0 )
      remainder = temp%10;
      sum = sum + remainder*remainder*remainder;
      temp = temp/10;

   if ( number == sum )
      cout<<"Entered number is an armstrong number.n";
      cout<<"Entered number is not an armstrong number.n";

   return 0;



armstrong number C++

Leave a Comment