Program to check whether the given number is armstrong or not in C++
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int n,m,num,res=0,dig;
cout<<"\nEnter the no. of digits :: ";
cin>>n;
cout<<"\nEnter a "<<n<<" digit number :: ";
cin>>num;
m=num;
while(num>0)
{
dig=num%10;
num=num/10;
res=res+pow(dig,n);
}
if(m==res)
cout<<"\n The number "<<m<<" is Armstrong Number.";
else
cout<<"\n The number "<<m<<" is not Armstrong Number.";
getch();
}
OUTPUT::
Enter the no. of digits :: 2
Enter a 2 digit number :: 23
The number 23 is not Armstrong Number.