Answer to Question #24355 in C++ for Aaron Stewart

Question #24355
write compile and run a c++ program to reverse the digits of a positive integer number. For example if the number 8735 is entered, the number displayed should be 5378.( hint: use do while ) After a units digit is displayed, dividing the number by 10 sets up the number for the next iteration
1
Expert's answer
2013-02-15T04:40:03-0500
#include <iostream>
using namespace std;

int main()

{

int num, rev;

cout <<"Input: ";
cin >> num;

cout <<"Output: ";

do
{
rev = num;
num=num/10;
cout << rev;
} while(num>0);

cout <<"
";

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS