Input student grades and report the # of students with A, B, C, & D.
Greetings,
I was given the task to create a program that:
1. Lets you input grades from only 10 students.
2. Prints a report with the number of students who got A, B, C, and Ds.
I've been trying my hardest to figure it out, I think I'm onto something but I just need a little push in the right direction, specially with the part where "grade" gets saved into the memory and then it is supposed to add to the counters of the grades A, B, C, and D respectively according to what the user has input.
If you can help me a little I'll appreciate it.
Thanks in advance.
Code:
#include <stdio.h>#include <stdlib.h>
#include <conio.h>
int main()
{
//initialize variables
int grade;
int A = 0;
int B = 0;
int C = 0;
int D = 0;
int count = 0;
printf( "Enter 10 student's grades:\n");
while ( count < 10 ) {
scanf("%i", &grade);
grade = getchar();
if ( grade >= 90){
A = A + 1;
}
else if ((grade >= 80) && (grade < 90)) {
B = B + 1;
}
else if ((grade >= 70) && (grade < 80)) {
C = C + 1;
}
else ((grade >= 1) && (grade < 70)); {
D = D + 1;
}
count = count+1;
}
printf( "%i students got A\n", &A);
printf( "%i students got B\n", &B);
printf( "%i students got C\n", &C);
printf( "%i students got D\n", &D);
return 0;
}