Storing all scores

I have a void function that asks the user for 5 different scores. This function should be called 5 different times in the main function, one time for every score. How do I get it to store all 5 different scores if I only have one variable?


1
2
3
4
5
6
7
8
9
10
11
12
void getJudgeData (double&score) {

	cout<<"Enter the judge's score:";
	cin>> score;

	while (score < 0 || score > 10) {
		cout<< "Invalid Score."<<endl; 
		cout<< "Enter judge's score:"; 
		cin >> score; 
	}
} 
Last edited on
u should use an array..
Have you learned about any of the STL containers yet?
As E A Student says you could use an array in which to store the five different scores
So, l2 should read .................for(int i=0;i<5;i++)
and l5 should read .................int a[i]=score;//now each score will be stored as an int in array a. (don`t forget to declare array a)
Your code needs to be consolidated somewhat because the first score input is not covered by the while loop clause.
Topic archived. No new replies allowed.