Home >>Cpp Programs >CPP Program to Reverse Number
In this example, we will see a C++ program through which we can print the digits in reverse order.
STEPS:
#include <iostream.h>
using namespace std;
int main()
{
int num;
int a = 0;
cout << "Enter a number: ";
cin >> num;
cout << "\n";
for (int i = 1; num > 0; i++) {
a = num % 10;
cout << a;
num = num / 10;
}
return 0;
}