Reverse the entered number in C++.

//Reverse the entered number in C++.

#include<iostream>

using namespace std;

int  main()
{
long n, rev, temp;
cout<<"Enter a number to reverse it : ";
cin>>n;

while(n>0)
{
temp=n%10;
rev=rev*10+temp;
n=n/10;
}
cout<<"The Reverse number is : "<<rev<<endl;
}


No comments

Post your comments

Powered by Blogger.