Armstrong Program in C++
Here we will write one of the most important program in C++ which is generally asked in any exam. Armstrong Number Program in C++ or Armstrong Program in C++
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int num,power=0,rem,temp;
cout<<"Enter any three digit number:";
cin>>num;
temp=num;
while(num!=0)
{
rem=num%10;
power+=pow(rem,3);
num=num/10;
}
if(temp==power)
{
cout<<"Armstrong number";
}
else
{
cout<<"Not an Armstrong number";
}
getch();
}
Output:
Enter any three digit number: 231
Not an Armstrong number
No comments :
Post a Comment