I made a program that reads golf scores and pars from a file.
It then assigns the appropriate comment depending on the score.
Everything works fine, but I also need the sum of all the scores.
How do I use a loop to read the file again and add the scores and return their sum.
Any help would be appreciated
Without looking at the source it's a little difficult to help you out. Here is the syntax for a basic while loop.
Alternatively, if you know the exact number of iterations try a for loop.
while( condition ) // example: while( bDone == false )
If you knew you wanted to loop 5 times you could do this. All this does is says while i is less than 5 keep executing code, and i++ simply increments the variable i AFTER the last line of code. If you want i to increment first, simply change i++ to ++i.
for( variable x; condition; increment )
// Do this
Hope this helped a little.
for( int i = 0; i < 5; i++ )