Hello happy people! Can use some help here I am new to programming.
This code is supposed to accept only ten inputs but it keeps going on forever I don't know what I am doing wrong
Code:
#include <stdio.h>
#include <conio.h>
int main( void)
{
int counter;
int grade;
int total;
int possible;
int total2;
int percent;
float average;
float average2;
total = 0;
total2 = 0;
counter = 0;
printf( "Enter grade: ");
scanf( "%d", &grade );
printf("Enter total points possible: ");
scanf("%d", &possible);
while (grade != -1) {
total = total + grade;
total2 = total2 + possible;
counter = counter + 1;
printf( "Enter grade: ");
scanf("%d", &grade );
printf( "Enter total points possible: ");
scanf( "%d", &possible );
}
if (counter <=10 ) {
average = ( float ) total/counter;
average2 = (float ) total2/counter;
percent = (average/average2)*100;
}
if (percent >= 90) {
printf("The student has %d perccent Therefore the student has an A ", percent);
}
else if (percent >=80){
printf("The student has %d percent Therefore the student has a B", percent);}
else if (percent>=70){
printf("The student has %d percent Therefore the student has a C", percent);}
else if (percent>=60){
printf("The student has %d percent Therefore the student has a D", percent);}
else if (percent <59){
printf("The student has %d percent Therefore the student has an F", percent);}
getch();
return 0;
}