63 189
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #12994 in C++ for madhurya

Question #12994
program to find the armstrong number between 100 and 999 using c++
Expert's answer
#include <iostream>
using namespace std;

bool
isArmstrongNumber(int number)
{
int sum = 0, temp = number,
remainder;
while(temp != 0)
{
remainder = temp % 10;
sum = sum +
remainder * remainder * remainder;
temp = temp / 10;
}
return (number
== sum);
}

int main()
{
for (int numberToTest = 100;
numberToTest <= 999; numberToTest++)
if
(isArmstrongNumber(numberToTest))
cout << numberToTest << "
";
cout << 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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions