#include<iostream>
using namespace std;
int main()
{
int r;
long number = 0, c, sum = 0, temp;
cout<<"Enter an integer upto which you want to find armstrong numbers\n"<<endl;
cin>>number;
cout<<"Following armstrong numbers are found from 1 to this number:"<<endl;
for( c = 1 ; c <= number ; c++ )
{
temp = c;
while( temp != 0 )
{
r = temp%10;
sum = sum + r*r*r;
temp = temp/10;
}
if ( c == sum )
cout<<c<<endl;
sum = 0;
}
return 0;
}
No comments:
Post a Comment