-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction.c
More file actions
47 lines (40 loc) · 886 Bytes
/
Function.c
File metadata and controls
47 lines (40 loc) · 886 Bytes
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
#include <stdio.h>
void Total(int kor, int eng, int math, int* total) {
*total = kor + eng + math;
}
void Average(int total, double* avg) {
*avg = total / 3.0;
}
void Grade(double avg, char* grade) {
switch ((int)avg / 10) {
case 10: case 9:
*grade = 'A';
break;
case 8:
*grade = 'B';
break;
case 7:
*grade = 'C';
break;
case 6:
*grade = 'D';
break;
default:
*grade = 'F';
break;
}
}
int main() {
int kor, eng, math, total;
double avg;
char grade;
printf("국어, 수학, 영어 성적 입력: ");
scanf("%d %d %d", &kor, &math, &eng);
Total(kor, eng, math, &total);
Average(total, &avg);
Grade(avg, &grade);
printf("총합: %d\n", total);
printf("평균: %.2lf\n", avg);
printf("등급: %c\n", grade);
return 0;
}