Thursday, 5 July 2012

Program to display reverse number or string of inputed numbe or string in c++.

#include<iostream>
using namespace std;

int reverse(int );

int main()
{
int num,k;
cout<<"Enter your number:";
cin>>k;
cout<<endl;
num=reverse(k);
cout<<"Reverse number is :"<<num;
   
return 0;
}

    int reverse(int a)
    {
    int j,n,rev;
   
//reverse number logic
        rev=0;
        while(a>0)
        {   
        j=a%10;
        rev=rev*10+j;
        a=a/10;
        }
    return rev;
    }