forked from muskancs11/21CPL27
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstructure.c
48 lines (45 loc) · 1.01 KB
/
structure.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
//structure to read,write and comute average-marks and students scoring above and below
#include <stdio.h>
#include <stdlib.h>
struct student
{
char usn[50];
char name[50];
int marks;
}s[10];
int main()
{
int n,i,countav=0,countbv=0;
float sum,average;
printf("Enter number of students\n");
scanf("%d",&n);
printf("Enter students information\n");
for(i=0;i<n;i++)
{
printf("Enter usn\n");
scanf("%s",s[i].usn);
printf("Enter name\n");
scanf("%s",s[i].name);
printf("enter marks\n");
scanf("%d",&s[i].marks);
}
for(i=0;i<n;i++)
{
sum=sum+s[i].marks;
}
average=sum/n;
printf("The average is %f\n",average);
for(i=0;i<n;i++)
{
if(s[i].marks>=average)
{
countav++;
}
else{
countbv++;
}
}
printf("The number of student above average is %d\n",countav);
printf("The number of student below average is %d\n",countbv);
return 0;
}