Help with a program

Hello, first time posting here. I have to make a program using arrays to get the highest score out of 10 games and the name of the game associated with the high score. I'm having trouble getting the name of the game to print out along with the high score, any pointers on how to get it working properly? Here's the particular area that I'm having problems with, thanks in advance. (I tried using the code format on the bottom but it doesn't seem to be working.)

void getHighestGraphics(string gameTitle[], int graphicScore[]) { // Function used to get highest graphic score.
int graphicMax = graphicScore[0];
int x = 0;

for (x = 0; x < 10; x++)
{
if (graphicScore[x] > graphicMax) {
graphicMax = graphicScore[x];

}
}
cout << "The highest rated graphics game is " << gameTitle[graphicMax] << " with a score of " << graphicMax << endl;
}
Save the index of the max value, not the value itself:

1
2
3
4
5
6
7
8
9
    int indexGraphicMax = 0;

    for (int x = 0; x < 10; x++)
    {
        if (graphicScore[x] > graphicScore[indexGraphicMax])
        {
            indexGraphicMax = x;
        }
    }
Thanks so much! I was breaking my head over that. I have one more question if you don't mind: The last part of my assignment I need to get two combined scores, store them in an array, and cout the game title with the highest combined score. I'm getting an error when trying to pass 3 parameters to the function. Is this even allowed? I'll post the code I tried.

1
2
3
4
5
6
7
8
9
10
11
12
void getHighestCombined(string gameTitle[],int graphicScore[], int replayValue[]) { // Function used to get highest combined score.
	int c = 0;
	int indexHighestCombined = graphicScore[0] + replayValue[0];

	for (c = 0; c < 10; c++) {
		if (graphicScore[c] + replayValue[c] > graphicScore[indexHighestCombined] + replayValue[indexHighestCombined]) {
			indexHighestCombined = c;
		}
		
	}
	cout << "The highest rated combined score game is " <<gameTitle[indexHighestCombined] << " with a score of" << graphicScore[indexHighestCombined] + replayValue[indexHighestCombined] << endl;
}


The error that I'm getting is:
'getHighestCombined': no overloaded function takes 2 arguments.

When I click on the error is comes to this line of code:

1
2
3
case 6:
			getHighestCombined(gameTitle,graphicScore,replayValue);
			break;



Thanks in advance!
Last edited on
Nevermind, I figured it out. Thanks a lot for the help! This site is great, I'm glad I came here for help. Take care
The only problem I see in that function getHighestCombined() is at line 3,
 
    int indexHighestCombined = graphicScore[0] + replayValue[0];
it should be
 
    int indexHighestCombined = 0;


Remember, indexHighestCombined is the index, which is the position where the value is located, not the value itself.

But that wasn't the question you asked.
The error that I'm getting is:
'getHighestCombined': no overloaded function takes 2 arguments.

That error arises from earlier in your program, where you apparently are passing only two parameters to the function?
Topic archived. No new replies allowed.