C++ Program to Reverse a Number


-

-

Example:

Copied
#include<iostream>
using namespace std;

int main()
{
    int num, rem, rev=0;
    cout << "Enter any Numbers: ";
    cin >> num;
    
    while(num!=0)
    {
        rem = num%10;
        rev = rem + (rev*10);
        num = num/10;
    }
    
    cout << "\nReverse Numbers: " << rev;
    return 0;
}

Output:

Enter any Numbers:
2021
Reverse Numbers: 1202