-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathsource.c
More file actions
32 lines (26 loc) · 734 Bytes
/
source.c
File metadata and controls
32 lines (26 loc) · 734 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
#include <stdio.h>
int main() {
int score[6] = {76, 82, 90, 86, 79, 62};
int credit[6] = {2, 2, 1, 2, 2, 3};
int stu_number;
float mean, sum;
int temp;
int i;
printf("please input your student number:");
scanf("%d" , &stu_number);
sum = 0;
temp = 0;
for(i = 0 ; i < 6 ; i++) {
sum = sum + score[i] * credit[i];
temp = temp + credit[i];
}
mean = sum / temp ;
if(mean >= 60) {
mean = mean - 60 ;
printf("the score of student number %d is %f higher than 60.\n", stu_number, mean);
} else {
mean = 60 - mean ;
printf( "the score of student number %d is %f lower than 60.\n", stu_number, mean ) ;
}
return 0;
}