C++ Program to Reverse a Number
Example:
#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
Share this page on:
Subscribe Email Updates
to get latest update