How to display highest value in a two part two dimensional array?


I'm completely lost on how to do this.

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
//mid/final.cpp – displays the highest score earned on a midterm exam and the
//highest score earned on a final exam

#include <iostream>

using std::cout;
using std::endl;

int main()
{
	//declare array - the first column contains the midterm scores, the second
	//column contains the final scores
	int scores[10][2] = {{78, 90}, {87, 88}, {65, 70}, {56, 100}, {74, 72},
						 {33, 47}, {87, 88}, {73, 73}, {79, 83}, {95, 89}};

	//declare variables
	int midTerm = scores[0][0]
	int finalScore = score[0][0]
	int high = 0; 

	//search for the highest value
	for (x = 0; x < 4; x = x + 1)
		for (y = 0;y < 5; y = y + 1)
			if (scores[x][y] > high)
			high = scores[x][y];
		//end if
		//end while 

//display lowest value
	cout << "Highest value: " << high << endl;

	return 0;
}  //end of main function 
1
2
3
4
5
6
7
for (x = 0; x < 10; x++)
  if (scores[x][0] > highest_midterm)
    highest_midterm = scores[x][0];

for (x = 0; x < 10; x++)
  if (scores[x][1] > highest_final)
    highest_final = scores[x][1];


Done!
Topic archived. No new replies allowed.