-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8.8.c
51 lines (45 loc) · 1.39 KB
/
8.8.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#define NUM_STUDENTS 5
#define NUM_QUIZZES 5
int main(void)
{
int grades[NUM_STUDENTS][NUM_QUIZZES];
int high, low, quiz, student, total;
for (int student = 0; student < NUM_STUDENTS; student++)
{
printf("Enter your grades for student %d: ", student + 1);
for (quiz = 0; quiz < NUM_QUIZZES; quiz++)
{
scanf("%d", &grades[student][quiz]);
}
}
printf("\nStudent Total Average\n");
for (student = 0; student < NUM_STUDENTS; student++)
{
printf("%4d ", student + 1);
total = 0;
for (quiz = 0; quiz < NUM_QUIZZES; quiz++)
{
total += grades[student][quiz];
}
printf("%3d %3d\n", total, total / NUM_QUIZZES);
}
printf("\nQuiz Average High Low\n");
for (quiz = 0; quiz < NUM_QUIZZES; quiz++)
{
printf("%3d ", quiz + 1);
total = 0;
high = 0;
low = 100;
for (student = 0; student < NUM_STUDENTS; student ++)
{
total += grades[student][quiz];
if (grades[student][quiz] > high)
high = grades[student][quiz];
if (grades[student][quiz] < low)
low = grades[student][quiz];
}
printf("%3d %3d %3d\n", total / NUM_STUDENTS, high, low);
}
return 0;
}