I would need some help writing this code, I have one made but having trouble getting it to work, any help is appreciated. Basically the number of grades is given by the user. The grades are stored in an array. Two functions are called for each student. One function will give the numeric average of their grades. The other function will give a letter grade to that average. Grades are assigned on a 10-point spread.
90-100 A
80- 89 B
70-79 C
60-69 D
Below 60 F
On line 9 you are trying to create a VLA, (Variable Length Array), this is not proper C++ code. The size of the areray needs to be known at compile time, so the compiler will know how much space to set aside for the array. Some compilers may allow the use of VLAs, but do not count on this.
You could replace the array "scores" with a 2D vector and you would not have to worry about how much or little is entered. You can also set up the vector with a beginning size if needed.
In the function "grades" you are comparing a "double" to an "int". This may work, but not the best approach. Consider: if (score >= 90.0). At least this way the 2 types will match.
I have one made but having trouble getting it to work
As the number of grades per student is determined at run-time and not compile time, a c-style array cannot be used to store these. A vector is needed. Consider: