The below code has been written aiming to generate all the armstrong* numbers below 1000.
*armstrong numbers:An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3^3 + 7^3 + 1^3 = 371.
#include<iostream>
using namespace std;
int main()
{
int n,sum=0,digit,a,b;
for(n;n<1000;n++)
{
a=n;
b=n;
for(b;b>=0;b/10)
{
digit=b%10;
sum+=(digit*digit*digit);
}
(sum==a)?cout<<a:cout<<" ";
}
return 0;
}