array

Create a 2-d array containing the scores of 4 athletes in last 6 events. Read the values from the user. Compute following
a. Highest score in 4th match
b. Average of any athlete (user tells the athlete number)
c. Average of a match (user tells the match number)

Nice little exercise. Here's a starting point, assumes that score is an int:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

const int NUM_EVENTS = 6; // cols
const int NUM_ATHLETES = 4; // rows

int main()
{
  int data[ NUM_ATHLETES ][ NUM_EVENTS ];

  for (int row = 0; row < NUM_ATHLETES; row++)
  {
    for (int col = 0; col < NUM_EVENTS; col++)
    {
      // TODO prompt for input, read score and store 
      // number in data[row][col]
    }
  }
  
  // TODO print data to check if input was read and stored correctly
  // Implement the remaining tasks
}
Topic archived. No new replies allowed.