77 902
Assignments Done
Successfully Done
In August 2019

Answer to Question #40113 in C++ for Asma

Question #40113
A positive integer number N is called as Armstrong if the sum of the cubes of its own digits is equal to the number itself. For example: the number 153 is Armstrong since 13 + 53 + 33 is equal to 1+ 125 + 27 which is equal to 153.
Write a C++ program that reads any positive integer and checks whether this number is Armstrong or not
Expert's answer
#include <iostream> // cout, cin
#include <cstdlib> // system
#include <cmath> // pow
using namespace std;

int arm(int val){
int cval=val;
int t=val; int n=0; // n- digit number
int res=0;
t=val;//take low order digit
val/=10;//shifts by one bit to the right
if(res>cval ) return -1; // accelerates by about 30% if the N = 9, it is more likely.
}while(val); // check the counting
return res;
int main ()
int val;
cout<<"Enter the number"<<endl;
if(arm(val) ==val) cout<<"this number is Armstrong"<<endl;
cout<<"this number is not Armstrong"<<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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions