Answer to Question #27496 in C++ for surabind Debbarma

Question #27496
wap to check wether a number is armstrong or not between 100 to 999
1
Expert's answer
2013-04-03T10:33:16-0400
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
/* Check every 3-digit number abc
* whether it's an armstrong number */
for (int a = 1; a <= 9; a++)
for (int b = 0; b <= 9; b++)
for (int c = 0; c <= 9; c++)
if (pow(a, 3) + pow(b, 3) + pow(c, 3) == 100 * a + 10 * b + c)
cout << a << b << c << endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS