Hi again,

I almost finished my code for an assignment but I have trouble outputting a percentage. Thanks in advance.

Need the program to output "[number] percent are passing grades.":


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



Code:
#include <stdio.h>
#include <stdlib.h>

int main() {
int grades, passingGrades, total, failingGrades;
double percentage;
passingGrades = 0;
failingGrades = 0;
while(grades != -1) {
 
printf("Enter the grades. Enter -1 to stop. \n");
scanf("%i", &grades);
if(grades > 100 || grades < -1) {
  printf("That is not a valid grade. \n");}
{
    if (grades == -1)
  {
   grades = -1;
  }
  else 
  if (grades <= 100 && grades >= 70)
  {
  passingGrades = passingGrades + 1;
  }
  else
  {
  grades = 0;
  }
  }
          }
printf("%i are passing grades. \n", passingGrades);

/* Need to add calculation of percentage! */
system("pause");

}