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.
#include <iostream>
usingnamespace 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!