Write a C++ Program to reverse a number.

Example:

To reverse a number, we need to extract and append the last digit from the original number to its reverse rev = rev*10 + num%10.

We have to remove the last digit once it has been appended to the reverse string num = num/10.

So let’s write the C++ program.

Output

Enter a Number: 243
Reverse: 342

If you have any doubts or suggestion then comment below.

Leave a Reply

Close Menu