Hello. I'm trying to read 4 sets of numbers from a file, sum them, average them and assign them a grade. This is what I have so far and it seems to be working for the first set just fine. My question is how would I go about streamlining this for the 12 other sets of numbers?
- Try to include the lines 16 - 34 inside of a while or a do...while loop controlled by the End Of File.
- Before return 0;don't forget to close the file.
@condor by chance have you heard of RAII? The file is closed automatically when it goes out of scope, there is no reason to close it manually unless you will be reusing it for some strange reason (and even then you would move-assign a new file instead).
Also, you should not loop until end of file - you should perform the input in the loop condition. Otherwise you may get garbage values the last time around.