Reverse Number program in C++

This article shows that Reverse Number Program in C++. We can reverse a number in C++ using loop and arithmetic operators. In this program, we are getting number as input from the user and reversing that number.

C++ Program to swap two numbers with and without third variable.

Let’s see a simple C++ example to reverse a given number.

    #include <iostream>  
    using namespace std;  
    int main()  
    {  
    int n, reverse=0, rem;    
    cout<<"Enter a number: ";    
    cin>>n;    
      while(n!=0)    
      {    
         rem=n%10;      
         reverse=reverse*10+rem;    
         n/=10;    
      }    
     cout<<"Reversed Number: "<<reverse<<endl;     
    return 0;  
    }  

Output:

Enter a number: 627 
Reversed Number: 726
Note: If you interested lo learn C++ through web, You can click here

Conclusion:

Hi guys, I can hope that you can know that how to write a Reverse Number Program in C++. If you like this post as well as know something new so share this article in your social media accounts. If you have any doubt related to this post then you ask in comment section.

Leave a Comment

WC Captcha + nine = thirteen