function next_garde to generates 20 random exam grades (between 20 and 100
, and 60 is the passing grade). For each failing student, the program calls a function add10 that adds 10 points to try to pass the student (only for failing students). The program counts the number of passing students and the grade average before and after the curve using a function avg_pass and does the same for failing students using a function avg_fail.
Instead of declaring "num" in your function you should create an array "num" and pass it to your function as a pointer next_grade(num); and you will get an array of 20 random numbers. (you weren't using an array in your code, so it couldn't work)
Also I replaced while loop with for loop for simplicity and set condition to "count < 20", because your "count <= 1" would only be executed once.
When there is an operating system (which is most cases), where does a C++ program start? [Hint: main()] You original post does not show that starting point. Start by showing that part even if it does little or nothing.
Here is some pseudo code which should get you started in the right direction:
set the four counts mentioned below to 0
set the four sums mentioned below to 0
for each student
calculate a random grade
if grade is a pass // student passes
increment passing student count
accumulate grade into passing student sum
else // student fails
increment failing student without curve count
accumulate grade into failing student uncurved sum
add 10 points to failing student grade
if grade is now a pass
increment curved passing student count
accumulate curved grade into curved passing student sum
else
increment curved failing student count
accumulate curved grade into curved failing student sum
end of for each student
// It is not clear which averages the problem statement calls for
// Display whichever are required by the problem statement.
display uncurved passing student average
display uncurved failing student average
display curved passing student average
display curved failing student average
I am not convinced that you are understanding the basics. So my suggested steps are below. At whichever step you have a problem, show your code and what error messages you received if any.
Write a program that does NOTHING but does compile, link, and execute.
Then do a program that creates and displays the student grades.
Then do a program that just averages the student grades.
Then do a program that averages the passing grades and failing grades without any adjustment.