-
Notifications
You must be signed in to change notification settings - Fork 0
/
PROGRAM STUDENT DATABASE.cpp
158 lines (144 loc) · 2.6 KB
/
PROGRAM STUDENT DATABASE.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include<iostream>
#define N 5
using namespace std;
class student
{
private:
float a[N];
int i,j,k;
public:
student()
{
for(i=0;i<N;i++)
{
cout<<"Enter marks of "<<i+1<<" student : ";
cin>>a[i];
}
}
//-------------------------------------------------------------------------------
void average_score()
{
float avg=0;
int C=N;
for(i=0;i<N;i++)
{
if(a[i] == -1)
{
C--;
i++;
}
avg = avg + a[i];
}
avg = avg/C;
cout<<"AVERAGE = "<<avg;
}
//-------------------------------------------------------------------------------
void highest_lowest()
{
float ht=0;
float lw=a[0]; //or select a[o]
for(i=0;i<N;i++)
{
if(a[i] == -1)
{
i++;
}
if(a[i]>ht)
{
ht=a[i];
}
if(a[i]<lw)
{
lw=a[i];
}
}
cout<<"HIGHEST MARK : "<<ht<<endl;
cout<<"LOWEST MARK : "<<lw<<endl;
}
//-------------------------------------------------------------------------------
void most_score()
{
float most;
int curr_cnt=0;
int prev_cnt=0;
float most_score;
for(i=0;i<N;i++)
{
if(a[i] == -1)
{
i++;
}
curr_cnt=0;
most=a[i];
for(j=0;j<N;j++)
{
if(most == a[j])
curr_cnt++;
}
if(curr_cnt > prev_cnt)
{
most_score = a[i];
}
prev_cnt = curr_cnt;//imps
}
// cout<<curr_cnt<<" "<<prev_cnt;
cout<<"MOST MARKS SCORE : "<<most_score<<endl;
}
//-------------------------------------------------------------------------------
void absent_students()
{
int cnt;
for(i=0;i<N;i++)
{
if(a[i] == -1)
cnt++;
}
cout<<"NUMBER OF STUDENT ABSENT : "<<cnt<<endl;
}
//-------------------------------------------------------------------------------
void display()
{
for(i=0;i<N;i++)
{
cout<<"Marks of "<<i+1<<" student : "<<a[i]<<endl;
}
}
};
//-------------------------------------------------------------------------------
main()
{
student s;
int op=-1;
while(op!=0)
{
cout<<"\n1.AVERAGE SCORE";
cout<<"\n2.HIGHEST AND LOWEST SCORE";
cout<<"\n3.MARKS SCORED BY MOST STUDENT";
cout<<"\n4.ABSENT STUDENTS";
cout<<"\n5.DISPLAY MARKS";
cout<<"\n6.EXIT";
cout<<"\n\nENTER CHOICE : ";
cin>>op;
switch(op)
{
case 1:
s.average_score();
break;
case 2:
s.highest_lowest();
break;
case 3:
s.most_score();
break;
case 4:
s.absent_students();
break;
case 5:
s.display();
break;
case 6:
op=0;
break;
}
}
}