C++ Program to Reverse Any Given Number Using Loop

Share on facebook
Share on linkedin
Share on twitter
Share on email
Use "ufd6qb86" For Offers
Reverse Any Number

This Program is Written in C++.

This Program is use to reverse any number.

Example: If the user will type 12345 then this program will reverse this value and you will get 54321 as a result.

This Program is written in C++ but Logic of this program can be implemented with the help of other languages too example C Language, C#, Java, PHP, JavaScript etc.

Code :

Output :



//write a program to reverse a Given Number ?


using namespace std;

 int n;
 int rev = 0;
 cout << "Enter a Number which you want to reverse : ";
 cin >> n;
 int temp = n;
 while( temp != 0)
  rev = rev * 10;
  rev = rev + temp%10;
  temp = temp/10;
 cout << "The Reverse of " << n << " is : " << rev;

Get 20% Off on Trading Fee Use "LG3RJV7Z"

More To Explore

Use "ufd6qb86" For Offers