Here you will get the program for Armstrong number in C++.
A number whose total of digits raised to control n is equivalent to itself is called Armstrong number. Here n is the absolute digits in the number.
For instance, 153 is armstrong number as 153 = 13 + 53 + 33 = 1 + 125 +27.
Program
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,m=0,p=0,x,y;
cout<<"Enter any number: ";
cin>>n;
y=n;
while(y!=0){
y=y/10;
p++;
}
y=n;
while(n!=0)
{
x=n%10;
m+=pow(x,p);
n=n/10;
}
if(y==m)
cout<<"The given number is an armstrong number";
else
cout<<"The given number is not an armstrong number";
return 0;
}
Output
Enter any number: 9
The given number is an armstrong number