C++ : a program to reverse a number


#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
int n,rev=0;
cout<<"Enter any number : ";
cin>>n;

while(n!=0)
{
int r=n%10;
rev=rev*10+r;
n=n/10;
}
cout<<"\n\nReversed number is : "<<rev;
getch();
return(0);

}

No comments:

Post a Comment