/* Program for checking and displaying whether the Entered Number is "Armstrong" or NOT. Number whose sum of cube of its digits is equal to itself is called Arm-strong Number e.g: 371=(3*3*3)+(7*7*7)+(1*1*1) */ #include <iostream> using namespace std; int main() { int sum = 0, a, n, b; cout << "Enter Number?\t"; cin >> n; a = n; while (a != 0) { b = a % 10; sum = (b*b*b) + sum; a = a / 10; } if (sum == n) cout << "The entered number is arm-strong\n"; else cout << "The entered number is not arm-strong\n"; return 0; }
This blog is about coding in some commonly used "High Level Languages" like C, C++, Java etc. At first, I will post here basic programs written in C++ language only.
Friday, November 21, 2014
C++ Program for "Arm-Strong" Numbers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment