Hello

My input should terminate when the user enters 0, but I am having problems with where to enter this statement. Please Help someone, anyone.

Thanks in advance, I am in class right now trying to get this problem working quick reply is greatly needed and appreciated. Here's my code:

# include <stdio.h>

int main (void) {

/* Variable declarations: */

int idno;

int test1;

int test2;

int final_test,total_number_of_A,total_number_of_B,tot al_number_of_C;

int total_number_of_D,total_number_of_F;

double semester_average;

total_number_of_A=0;

total_number_of_B=0;

total_number_of_C=0;

total_number_of_D=0;

total_number_of_F=0;

double class_average;

class_average=0;

semester_average=0;

int number_of_students;

number_of_students=0;

/* Function body: */

printf ("***> Enter student idno:");

scanf ("%d", & idno);

printf ("***> Enter test1:");

scanf ("%d", & test1);

printf ("***> Enter test2:");

scanf ("%d", & test2);

printf ("***> Enter final_test:");

scanf ("%d", & final_test);

while (idno != 0) {

semester_average=0.20*test1+0.30*test2+0.50*final_ test;

printf ("The semester average is %lf\n", semester_average);

if (semester_average >= 90 && semester_average <= 100)

printf ("The letter grade is A\n");

total_number_of_A = total_number_of_A+1;

if (semester_average >= 80 && semester_average <= 89)

printf ("The letter grade is B\n");

total_number_of_B = total_number_of_B+1;

if (semester_average >= 70 && semester_average<= 79)

printf ("The letter grade is C\n");

total_number_of_C = total_number_of_C+1;

if (semester_average >= 60 && semester_average <= 69)

printf ("The letter grade is D\n");

total_number_of_D = total_number_of_D+1;

if (semester_average >= 0 && semester_average <= 59)

printf ("The letter grade is F\n");

total_number_of_F = total_number_of_F+1;

/* end if */

printf ("***> Enter student idno:");

scanf ("%d", & idno);

printf ("***> Enter test1:");

scanf ("%d", & test1);

printf ("***> Enter test2:");

scanf ("%d", & test2);

printf ("***> Enter final_test:");

scanf ("%d", & final_test);

} /* end while */

class_average = (4*total_number_of_A + 3*total_number_of_B + 2*total_number_of_C + 1*total_number_of_D)/number_of_students;

printf ("Grade distribution:");

printf ("A total_number_of_A_grades=total_number_of_A_grades+ 1");

printf ("B total_number_of_B_grades=total_number_of_B_grades+ 1");

printf ("C total_number_of_C_grades=total_number_of_C_grades+ 1");

printf ("D total_number_of_D_grades=total_number_of_D_grades+ 1");

printf ("F total_number_of_F_grades=total_number_of_F_grades+ 1");

printf ("Class average: %lf", class_average);

return 0;

} /* end function main */