By the way, I'm pretty sure you're doing it a bit differently than you were asked to do but I will first explain how to modify your current program.
Your function
int InArr () {...}
does not have a return statement. Functions that have a return type other than void MUST have a (valid) return statement.
So changing that function to this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
int* InArr() {
int arr[5];
cout << "\t You will be requested to enter 5 values but wont output them";
for (int i = 0; i < 5; i++) {
cout << "\tEnter a number: ";
cin >> arr[i];
} cout << endl;
return arr;
}
|
should work.
int* specifies that we're returning a pointer to integer. In C++ you cannot return C-style arrays by value, so we have to return a pointer. But it's the same thing though, in use, so treat it like a regular array.
However, I think what you were asked to do is make a function that takes an array as parameter and populate it, not make a function to both create and populate an array. Your displayin' function is just fine though.
If you create an array in the function itself then you have to assign something with it otherwise it will just cease to exist after the function finishes executing. So you can instead take an array as parameter (would make sense to pass the array by reference, then you do not need to reassign) and populate it.