-
Notifications
You must be signed in to change notification settings - Fork 118
/
LAB13.c
61 lines (54 loc) · 1.21 KB
/
LAB13.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
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdio.h>
struct stud
{
int rollno, s1, s2, tot ;
char name[10] ;
float avg ;
}s[10] ;
float compute( struct stud S[], int n )
{
int i;
float sum=0 ;
for ( i = 0 ; i < n ; i++ )
{
sum = sum + S[i].avg ;
}
return (sum/n);
}
void display( struct stud s )
{
printf("%d \t %s \t\t %d \t %d \t %d \t %.2f \n", s.rollno,s.name,s.s1,s.s2,s.tot,s.avg);
}
void main()
{
int i, n ;
float mean;
printf("Enter the number of students : ") ;
scanf("%d", &n) ;
for(i = 0 ; i < n ; i++)
{
printf("\nEnter the roll number : ") ;
scanf("%d", &s[i].rollno) ;
printf("\nEnter the name : ") ;
scanf("%s", s[i].name) ;
printf("\nEnter the marks in 2 subjects : ") ;
scanf("%d %d", &s[i].s1, &s[i].s2) ;
s[i].tot = s[i].s1 + s[i].s2 ;
s[i].avg = s[i].tot / 2.0 ;
}
mean = compute( s,n);
printf("\nBelow Average Students\n");
printf("\nRoll No. Name \t\tSub1\t Sub2\t Total\t Average\n\n") ;
for(i = 0 ; i < n ; i++)
{
if( s[i].avg < mean )
display(s[i]);
}
printf("\nAbove Average Students\n");
printf("\nRoll No. Name \t\tSub1\t Sub2\t Total\t Average\n\n") ;
for(i = 0 ; i < n ; i++)
{
if( s[i].avg >= mean )
display(s[i]);
}
}