The following is code from a homework assignment using arrays. I am having trouble with function FindHighScore. Any help would be helpful. The format below is required, so just need help on figuring out how to get highest score... Thanks
// THIS PROGRAM FINDS THE HIGHEST SCORE
// OF 20 SCORES. A FILE ON THE "A"
// DRIVE IS USED TO PROVIDE INPUT
// (SCORES) TO THE ARRAY.
#include <iostream.h>
#include <fstream.h>
// FUNCTION PROTOTYPES
//
// FUNCTION PROTOTYPE FOR USER COMMENTS
void usercomments();
//
// FUNCTION PROTOTYPE TO FIND HIGHEST SCORE
short FindHighScore(short [], short);
//
void main()
{
//DECLARE AND INITIALIZE VARIABLE
short number = 0;
// DECLARE AND INITIALIZE NUMERIC ARRAY
// THE ARRAY NAME IS scores AND IT CONTAINS 20 NUMBERS
// THE DATA TYPE IS SHORT.
// INITIALIZE ALL ELEMENTS TO BE ZERO
short scores[20];
//
// CALL usercomment FUNCTION
usercomments();
//
// OPEN FILE FOR INPUT
ifstream inFile;
inFile.open("a:scores8.txt", ios::in);
// VERIFY FILE WAS OPENED SUCCESSFULLY
if (!inFile.fail())
{
// ENTER SCORES INTO THE ARRAY
// USE A FOR LOOP
for (int x=0; x<=19; x++)
// INPUT THE NUMBERS FROM THE FILE TO THE ARRAY
inFile >> scores[x];
x = x + 1;
//
// CLOSE THE FILE
inFile.close();
//
// CALL FindHighScores FUNCTION
number = FindHighScore(scores, 20);
//
// OUTPUT HIGHEST SCORE
cout << "\n" << "The highest score is: " << number << "\n\n";
}
else
cout << "Error opening file." << endl;
// END IF
//
cout << "\n\n\nProgram has terminated.\n\n\n\n\n";
} // END OF MAIN
// PROGRAMMER-DEFINED FUNCTION DEFINITIONS
//
// FindHighScore FUNCTION
short FindHighScore(short nums[], short)
{
// THIS FUNCTION FINDS THE HIGHEST SCORE
// IN THE ARRAY
short high = 0; // COUNTER
short number = 0;
for ( int x = 0; x > number; x++)
{
if(nums[x] > number)
high = high + 1;
}
//
return number;
} // END OF FindHighScore FUNCTION
//
// Usercomments FUNCTION
void usercomments()
{
cout << "This program finds the highest score"
<< " of 20 scores. A file on the A-drive\n";
cout << "is used to provide input (scores) to the array.\n\n";
} // END OF usercomment FUNCTION