-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct-based-code.cpp
More file actions
47 lines (47 loc) · 1.43 KB
/
struct-based-code.cpp
File metadata and controls
47 lines (47 loc) · 1.43 KB
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
#include <iostream>
#include <string>
using namespace std;
const int n=2;
struct Student{
int reg;
char name[50];
float cgpa;
string adm_date;
};
Student* input_data();
void display(Student []);
int main(){
Student* ptr;
ptr=input_data();
return 0;
}
Student* input_data(){
Student data[n];
for(int i=0;i<n;i++){
cout<<"Enter Registration number of student "<<i+1<<" : ";
cin>>data[i].reg;
cin.ignore(99999, '\n');
cout<<"Enter Name of student "<<i+1<<" : ";
cin.getline(data[i].name,50);
cout<<"Enter CGPA of student "<<i+1<<" : ";
cin>>data[i].cgpa;
cout<<"Enter Admission date of student "<<i+1<<" : ";
cin>>data[i].adm_date;
cout<<"Data of student "<<i+1<<" entered successfully!!";
cout<<endl;
cout<<endl;
}
cout<<"***********************************************************************"<<endl;
display(data);
return 0;
}
void display(Student data[]){
for(int i=0;i<n;i++){
cout<<"The Registration number of student "<<i+1<<" is: "<<data[i].reg<<endl;
cout<<"The Name of student "<<i+1<<" is: "<<data[i].name<<endl;
cout<<"The CGPA of student "<<i+1<<" is: "<<data[i].cgpa<<endl;
cout<<"the Admission date of student "<<i+1<<" is: "<<data[i].adm_date<<endl;
cout<<"***********************************************************************";
cout<<endl;
}
}