I need to take the integer and output the digits in reverse. For example, if the input is 245 then it should output 542. I've determined the number of digits, but I'm not sure what to do next.
It's also telling me that there's an undefined reference to reverseDigit, and won't compile.
#include <iostream>
usingnamespace std;
int ReverseDigits(int x);
int GetSize(int x);
int main(int argc, char** argv) {
int num = 0;
cout << "Please enter an integer. ";
cin >> num;
cout << "There are " << GetSize(num) << " digits." << endl;
cout << "The reverse is " << ReverseDigits(num) << endl;
return 0;
}
int ReverseDigits(int x)
{
int out = 0;
while (x > 0)
{
out *= 10;
out += x%10;
x /= 10;
}
return out;
}
int GetSize(int x)
{
int size;
for (size = 0; x > 0; size ++)
{
x /= 10;
}
return size;
}