Help Solving C program?

We want to count how many passing grades are entered. We don’t know how many grades there will be. Use a sentinel controlled while loop that will ask the user to enter student grades until a value of -1 is entered.   Use a counter variable to count all the grades that are passing grades, where 70 is the minimum passing grade. If there are any grades that are out of the range 0 – 100, present an error message to the user, and do not count that grade as passing. We also would like to see what percentage of the valid grades are passing (This is calculated by dividing number of passing grades by number of valid grades and multiplying by 100). 

Grades Entered:                                      Expected Results 





123                                                            “That is not a valid grade!” 


-1                                                               You entered 4 passing grades. 

80.0% of the valid grades entered are passing grades.

2 Answers

  • Clive
    Lv 7
    3 weeks ago

    What does this have to do with personal finance?

  • Amy
    Lv 7
    1 month ago

    Since the instructions say "Use a sentinel-controlled while loop" without explaining what that means, you must have already seen those. Start by writing that code.

    Outside the code you ll need to define two more variables, in order to print the summary data at the end. Initialize to zero a counter for number of passing grades and a counter for valid grades. After the loop, write the code to output that summary.

    Inside the loop, you ll have some "if" statements to execute different blocks of code depending on whether the grade is in the 0-69 range, 70-100 range, or neither.

    You should be able to figure out what the code needs to do in each of those cases.

Still have questions? Get your answers by asking now.