-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtotal_marks.c
More file actions
42 lines (31 loc) · 969 Bytes
/
total_marks.c
File metadata and controls
42 lines (31 loc) · 969 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
#include<stdio.h>
#include<string.h>
struct Class{
char name[30];
char address[50];
};
struct Class student[100];
struct Marks{
int sub1;
int sub2;
int sub3;
int total;
};
int main(){
struct Marks student[3] = {{45,67,81,0},{75,53,69,0},{57,36,71,0}};
struct Marks total = {0,0,0,0};
for(int i = 0; i <= 2; i++){
student[i].total = student[i].sub1 + student[i].sub2 + student[i].sub3 ;
total.sub1 += student[i].sub1;
total.sub2 += student[i].sub2;
total.sub3 += student[i].sub3;
total.total += student[i].total;
}
printf("STUDENT TOTAL\n\n");
for(int i = 0; i <= 2; i++){
printf("Student[%d] %d\n",i+1,student[i].total);
}
printf("\n\n\nSUBJECT TOTAL\n\n");
printf("%s %d\n%s %d\n%s %d\n","Subject 1",total.sub1,"Subject 2",total.sub2,"Subject 3",total.sub3);
printf("\nGrand Total = %d\n",total.total);
}