-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path12_Student.cpp
executable file
·67 lines (56 loc) · 966 Bytes
/
12_Student.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
#include <iostream>
using namespace std;
class Student{
char stud_name[20], stud_branch[20];
int stud_rollno;
static int num;
public:
void read();
void write();
static int count();
};
int Student::num;
int main(){
int c, i;
Student s[20];
do{
cout<<"\n1. Add\n2. Display\n0. Exit\n:";
cin>>c;
switch(c){
case 1:
if(Student::count() == 20)
cout<<"List Full\n";
else
s[Student::count()].read();
break;
case 2:i = Student::count();
while(i > 0){
--i;
s[i].write();
}
break;
case 0:break;
default :cout<<"Invalid option\n";
}
}while(c != 0);
return 0;
}
void Student::read(){
cout<<"Name : ";
cin>>stud_name;
cout<<"Roll no: ";
cin>>stud_rollno;
cout<<"Branch : ";
cin>>stud_branch;
num++;
}
void Student::write(){
cout<<"Name : "<<stud_name;
cout<<"\nRoll no: "<<stud_rollno;
cout<<"\nBranch : "<<stud_branch;
cout<<"\n";
num++;
}
int Student::count(){
return num;
}