Answer:
#include <iostream>
using namespace std;
int main() {
int n, reversedNumber = 0, remainder;
cout << "Enter a number: ";
cin >> n;
int length = to_string(n).length();
if (length == 4){
while(n != 0) {
remainder = n%10;
reversedNumber = reversedNumber*10 + remainder;
n /= 10;
}
cout << "Reversed Number = " << reversedNumber << endl;
}
else{
cout << "Invalid Input!" << endl;
}
return 0;
}
Step-by-step explanation:
So, it's pretty easy. It finds the remainder to reverse the number and for the invalid input part, you convert the input...
Step-by-step explanation: