Program that will store 10 input numbers and display highest

So, I am in my first beginning Cpp course and I have been grasping it very well up until this point. Arrays/loops. I have been working on an assignment for 3 days now and I truly can't seem to grasp it. The assignment is as follows:

"Write a program that declares an array of type double of size 10. In the main() function, the
program should have a loop that asks the user to input 10 numbers. The numbers input by the
user should be stored in the array.
Your program should then pass the array to a function that searches for the largest number in the
array. The function should return the largest number to main(). The main() function should then
display a message as follows:
The highest class score on the test is <maximum_value>
The highest score should be displayed to one decimal place using the setprecision function found
in the iomanip library."

This is what I have so far, I know its far from complete and probably wrong as it is. Any help would be very much appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iomanip>
#include <iostream>

using namespace std;

double score[10]; //array
int input;


int main()

{
	cout << "Enter score for student #1 " << " " << endl;
	cin >> input;
	cout << "Enter score for student #2 " << " " << endl;
	cin >> input;
	cout << "Enter score for student #3 " << " " << endl;
	cin >> input;
	cout << "Enter score for student #4" << " " >> endl;
	cin >> input;
	cout << "Enter score for student #5" << " " >> endl;
	cin >> input;
	cout << "Enter score for student #6" << " " >> endl;
	cin >> input;
	cout << "Enter score for student #7" << " " >> endl;
	cin >> input;
	cout << "Enter score for student #8" << " " >> endl;
	cin >> input;
	cout << "Enter score for student #9" << " " >> endl;
	cin >> input;
	cout << "Enter score for student #10" << " " >> endl;
	cin >> input;

}

You'll use the loop to replace all those individual messages/inputs with just one. Since you know how many times you need to loop, I'd use a for loop.

Since you're storing the values in the array, not an individual variable, I'd probably start the for loop at 0.

for (int i = 0; i < 10; i++)
//output message
//store input in array element
Topic archived. No new replies allowed.