Reverse of digits

Description:

Write a c++ program to find the reverse of digits of the given number Test Case 1 Input (stdin) 1234 Expected Output The reverse is 4321 Test Case 2 Input (stdin) 367 Expected Output The reverse is 763

Program :

#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<<"The reverse is "<<reverse<<endl;    

return 0;  

}