#include <iostream>
using namespace std;
#include <cmath>
#include <conio.h>
class arm
{
int num1;
public:
int sum, rem, i, num, count;
arm(int num1)
{
this->num1 = num1;
}
void check()
{
if (num1 > 0)
{
for (i = 0; i <= num1; i++)
{
// count gives the number of digits in i
count = 0;
// store value of i in num
num = i;
// count the number of digits in num and i
while (num > 0)
{
++count;
num /= 10;
}
// initialize sum to 0
sum = 0;
// store i in num again
num = i;
// get sum of power of all digits of i
while (num > 0)
{
rem = num % 10;
sum = sum + pow(rem, count);
num /= 10;
}
// if sum is equal to i, then it is Armstrong
if (sum == i)
{
cout << i << "\t ";
}
}
}
else
cout << "number entered is less than 1\n";
}
};
int main()
{
system("cls");
int num1;
cout << "enter number upto which you want armstongs\n";
cin >> num1;
arm a(num1);
system("cls");
cout << "armstongs upto " << num1 << endl;
a.check();
return 0;
}