Armstrong Number Using C++
What is Armstrong Number ?
For Example:
371 is An Armstrong Number
3^3 + 7^3 +1^3 = 371
========================================================================
#include<iostream>
using namespace std;
main()
{
int num;
int sum=0;
int digit;
cout<<"Enter A Number\n";
cin>>num;
int i=num;
while(num>0)
{
digit=num%10;
sum=sum+(digit*digit*digit);
num=num/10;
}
if(sum==i)
{
cout<<sum<<" Is Armstrong Number \n ";
}
else
cout<<"Is NOT Armstrong Number \n";
}
======================================================================
0 comments:
Post a Comment