#include <stdio.h>
int main() {
int grade;
int sum = 0;
int count = 0;
printf("\n\n\tAverage Grade Checker in C with Remarks\n\n");
printf("\n\tEnter grades (enter -1 to finish):\n");
while (1) {
printf("\n\tEnter grade: ");
scanf("%d", &grade);
if (grade == -1) {
break;
}
sum += grade;
count++;
}
if (count == 0) {
printf("\nNo grades entered. Exiting...\n");
return 0;
}
double average = (double)sum / count;
printf("\n\tAverage grade: %.0f\n", average);
printf("\n");
// Determine the corresponding grade category
if (average == 100) {
printf("\n\tExcellent\n");
} else if (average >= 95 && average <= 99) {
printf("\n\tVery Satisfactory\n");
} else if (average >= 90 && average <= 94) {
printf("\n\tSatisfactory\n");
} else if (average >= 85 && average <= 89) {
printf("\n\tOutstanding\n");
} else if (average >= 80 && average <= 84) {
printf("\n\tGood\n");
} else if (average >= 75 && average <= 79) {
printf("\n\tPass\n");
} else {
printf("\n\tFail\n");
}
printf("\n\n");
printf("\tEnd of Program\n\n");
return 0;
}
No comments:
Post a Comment