-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathstruct-stud-database.cpp
More file actions
67 lines (54 loc) · 963 Bytes
/
struct-stud-database.cpp
File metadata and controls
67 lines (54 loc) · 963 Bytes
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.h>
#include <conio.h>
#include <stdio.h>
struct Student {
int rollno;
char name[30];
int cl;
};
Student stud_data[3];
void enter(void);
void display(int a);
int main (){
enter();
int sno,i,flag=0;
char ch;
do{
cout<<"Enter student rollno. to get info";
cin>>sno;
for(i=0;i<3;i++)
{
if(stud_data[i].rollno==sno)
{
flag=1;
display(i);
break;
}
}
if(flag!=1)
cout<<endl<<"No student found";
cout<<endl<<"Continue ?(y/n)";
cin>>ch;
}while(ch=='y');
return 0;
}
void enter(void) {
for(int i=0;i<3;i++)
{
cout<<"Enter student roll no. ";
cin>>stud_data[i].rollno;
cout<<"Enter student name ";
gets(stud_data[i].name);
cout<<"Enter student class ";
cin>>stud_data[i].cl;
}
return ;
}
void display(int a){
cout<<"Student data for roll no. "<<stud_data[a].rollno<<endl;
cout<<"Student name ";
cout.write(stud_data[a].name,30);
cout<<endl;
cout<<"Class: "<<stud_data[a].cl;
return ;
}