Sunday, 4 January 2015

Cpp Program to find the Reverse of a number


This is a Cpp program which finds the reverse of a given  number.

PROGRAM :
#include <iostream>

using namespace std;

int main()
{
    int n,copy_num,remainder,reverse = 0;
    cout << "Enter a number : \t" ;
    cin >> n;
    copy_num = n;

    while(n)
    {
        remainder = n%10;
        reverse = reverse*10+remainder;
        n=n/10;
    }
    cout << "\nThe Reverse of " << copy_num << " is : " << reverse << endl;
    return 0;
}

OUTPUT :


Cpp Programming - Reverse of a number