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; }
Comments
Leave a comment