Using a function to reverse an input number

So I'm very new to c++ and I'm taking a class for it right now but I feel like I'm not really understanding some of the material. I've tried the textbook and notes and managed the below code, but instead of reversing the number it only outputs 0.

According to the directions I'm not allowed to have any cin or cout statements in the function itself, only in main. Anyway, any help or tips to help me understand this better/fix this code would be greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #include <iostream>

using namespace std;

int reverseDigit ();

int main(int argc, char** argv) {
int userNum, reverse;
cout<<"Input a number to reverse: ";
cin>>userNum;

reverse = reverseDigit ();
cout<<"Your new number is: "<<reverse;

	return 0;
}

int reverseDigit ()
{int reverseNum, userNum;
reverseNum=reverseNum*10;
reverseNum=reverseNum%10;
userNum=userNum/10;
return reverseNum;
}



I'll bet it's something stupid or simple, but I really appreciate anyone willing to help!
Last edited on
first try simpler things...
1. try to reverse inside main function.
2. learn how to send values from one function to another.
Topic archived. No new replies allowed.