A positive integer is called an Armstrong number if the sum of cubes of individual digit is equal to that number itself. Test Case 1 Input (stdin) 153 Expected Output Is an Armstrong number Test Case 2 Input (stdin) 15 Expected Output Is not an Armstrong number
#include <iostream> using namespace std; int main() { int origNum, num, rem, sum = 0; cin >> origNum; num = origNum; while(num != 0) { rem = num % 10; sum += rem * rem * rem; num /= 10; } if(sum == origNum) cout <<" Is an Armstrong number"; else cout << " Is not an Armstrong number"; return 0; }