### Multiple inputs

I have an exercise in my book that requires me to get five different inputs as reference variables in a function, and I will have to pass them to a different function. The only way I know to get the function to ask for five different numbers is with a for loop. We haven't learned arrays yet, so I can't use that. How do I get the loop to store five variables when it can only define one?
Don't use a loop. Define 5 separate variables.
 ``12`` `````` int v1, v2, v3, v4, v5; cin >> v1 >> v2 >> v3 >> v4 >> v5;``````

I am required to use a function that asks for a number. I'll have to make that function repeat five times to get all five numbers. Can I store each input from each iteration of the loop in a different variable?
 Can I store each input from each iteration of the loop in a different variable?

Sure. You can use a series of if statements or a switch statement.
 ``1234567`` `````` for (int i=1; i<=5; i++) { if i==1) cin >> v1; if (i== 2) cin >> v2; ... etc }``````

Or:
 ``12345678`` `````` for (int i=1; i<=5; i++) { switch (i) case 1: cin >> v1; break; case 2: cin >> v2; break; ... etc }``````

Thankyou
In the same program, I have to create another funtion that dictates the lowest of the five numbers. I know how to do that. But, the funtion that that function resides in is supposed to drop the lowest of the numbers. I'm not sure how to make the function drop the lowest number. I have to average the remaining four after the lowest is dropped.
I worded that wrong. The secondary function is supposed to identify the lowest number, and return that number to the function that it resides in. So the bigger function will have to drop the lowest number.
Here is what I have so far, to give a general idea of what functions there are.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566`` `````` #include using namespace std; void getScore(int &, int &, int &, int &, int &); void calcAverage(); int findLowest(int); int score1, score2, score3, score4, score5, count; int main () { cout<<"Welcome. The intent of this program is to intake five test scores from the \n"; cout<<"user, take out the lowest score, and average them together. \n"; cout<<"When asked to input a score, please do not enter a number less than 0 or higher than 100.\n"; for (count=1; count<=5; count++) { getScore(score1, score2, score3, score4, score5); } calcAverage; } void getScore(int &sc1,int &sc2,int &sc3,int &sc4,int &sc5) { int test; cout<<"Please enter test score " <>test ; while (test>100||<0) {cout<<"Your entry is invalid, please try again: "; cin>>test; switch (count) case 1: test=sc1; break case 2: test=sc2; break case 3: test=sc3; break case 4: test=sc4; break case 5: test=sc5; } calcAverage { findlowest(int lowest); } int find lowest(int lowest) { ``````
Topic archived. No new replies allowed.