My code is about getting numbers from the user and finding the mean of the combined numbers. What I have done is create function called mean that does exactly that. In my main code I have the array and the a variable which ask the user before hand how many numbers they are going to input. I then use that variable in a for loop. I finally end the code with calling the function and dividing it by the number of entries which was given in the begging of the code as stated above. My problem is why isn't the user entries not going into the array.
#include <iostream>
using namespace std;
float mean(float x, float y...) {
float answer = (x + y);
return answer;
}
int main() {
int ask;
float numbers[] = {};
cout << "how many number do you want to add";
cin >> ask;
for (int i = 0; ask; i++) {
cout << "please enter your" << i << "number";
cin >> numbers
}
cout << mean(numbers) / ask
}