-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstustruct.c
45 lines (32 loc) · 936 Bytes
/
stustruct.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
#include <stdio.h>
typedef struct students {
char name [20];
char address [100];
float cmarks;
float ismarks;
} students;
float getavg(students [], int);
int main() {
const int studsize = 3;
students studlist[studsize];
for (int i = 0; i < studsize; i++)
{
printf("Enter the student's name." , i+1);
scanf("%s" , studlist[i].name);
printf("Enter the student's address." , i+1);
scanf("%s" , studlist[i].address);
printf("Enter the student's C Programming grade." , i+1);
scanf("%d" , studlist[i].cmarks);
printf("Enter the student's Information Systems grade." , i+1);
scanf("%d" , studlist[i].ismarks);
}
printf("The average C Programming grade is");
printf("Average grade = %.2f" , getavg(studlist , studsize));
}
float getavg(students stu[], int size)
{
float avg = 0.0;
for (int i = 0; i < size; i++)
avg += stu[i].cmarks;
return avg/size;
}