Answer to Question #280655 in C for Tharu

Question #280655

Requirements:

(1) Convert the inputted 3-digit integer, the single digit to a hundred digit, and the hundreds digit to a single digit, and generate a new inverted number from the converted 3 digits.

(2) Arbitrary 3-digit integers are input by keyboard.

(3) When outputting the result, the required form is: original number: converted number.


1
Expert's answer
2021-12-17T06:51:50-0500
#include <iostream>
using namespace std;


int main()
{
    int num,rev = 0;
    
    cout<<"Enter a Number: ";
    cin>>num;
    
    while (num > 0)
    {
        rev = (rev * 10) + (num % 10);
        num = num / 10;
    
    }
    
    cout<<rev<<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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS