Friday, September 2, 2016

Tags

PROGRAM TO PRINT ARMSTRONG NUMBERS UPTO 500:

#include<iostream>
#include<cmath>
using namespace std;
main()
{
int num,temp,d,r=0;
cout<<"ARMSTRONG NO";
for(int i=0;i<501;++i)
{
temp=i;
while(temp!=0)
{d=temp%10;
temp=temp/10;
r+=pow(d,3);
}
if(r==i)
{
cout<<" "<<i;
}
r=0;}
}