First, your getArray() function has no return type. Why are you assigning a return from this function to int e? Same with the reverseArray(). I'm not sure what compiler you are using, but I'm pretty sure (without throwing it in mine) that it shouldn't even compile. Hmm, it does compile, but with a ton of warnings that should have told you about just that thing. Anyway, moving on.
Now, in your getarray() function you are not assigning the input to the array. You are assigning the value in element [5] of the array (which, to be honest, isn't even IN the array you declared) to the variable userInput. Assignment works from right to left. IE, the value on the right is placed on into the variable on the left. Also, array elements start at 0. So, if you have an array of size N, the elements are held in array[0] to array[n-1]. Array[5] is actually 1 beyond the end of the array and so spits out gibberish since the data in that location is undefined.
To input to an array (or output from one) it's typical to use a for loop like you did, but you use the counter variable in the array itself to iterate over each element of the array, like this:
1 2 3 4 5
|
for (int i = 0; i < 5; i++) // assuming size is a variable holding
{ //the size of the array
std::cout << "Enter a number:";
std::cin >> array[i];
}
|
Here you don't need the userInput variable for an intermediary, you can input directly to the array. Note though that if you change the array size you will need to change function itself. A better solution would be to change the function to accept the array size as an additional parameter.
One final note: Don't take this the wrong way, we all had to start somewhere, but you made a lot of fundamental errors in this program so I'd re-read or find some new articles on variables, assignment and declaration, functions, and the like. :)