#include <iostream>
#include <limits.h>
using namespace std;
int main() {
cout << "Enter an Integer : ";
int n;
cin >> n;
cout << endl;
int res = 0;
while(n != 0){
int digit = n % 10;
// If reversing n causes the value to go outside the signed 32-bit integer range
if( res > INT_MAX/10 || res < INT_MIN/10){
cout << "Reached Out of Range of INT ..!" << endl;
return 0;
}
res = (res * 10) + digit;
n = n / 10;
}
cout << "Reverse : " << res << endl;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: