-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighestmarksusingclasses.cpp
More file actions
68 lines (57 loc) · 1.58 KB
/
Highestmarksusingclasses.cpp
File metadata and controls
68 lines (57 loc) · 1.58 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
using namespace std;
class student
{
public:
char name[20];
float marks;
int rollnumber;
void get_student_details()
{
cout<<"Enter the student's name , marks , rollnumber"<<endl;
cin>>name;
cin>>marks;
cin>>rollnumber;
cout<<endl<<endl;
}
void display_student_details()
{
cout<<endl<<endl<<"Student name : "<<name<<endl;
cout<<"Student marks : "<<marks<<endl;
cout<<"Student rollnumber : "<<rollnumber<<endl<<endl;
}
float marksreturn()
{
return marks;
}
};
int main()
{
student s[20];
int stud_num;
float temp_marks = 0.0;
int loc;
cout<<"How many students data do you want to enter ?"<<endl;
cin>>stud_num;
for (int i = 1; i <= stud_num; i++)
{
s[i].get_student_details();
}
cout<<endl<<"-----------------------------------------------------"<<endl;
cout<<endl<<endl<<"The student details captured till now are as follows"<<endl;
for (int j = 1; j <= stud_num; j++)
{
s[j].display_student_details();
}
cout<<endl<<"-----------------------------------------------------"<<endl;
for (int k = 1; k <= stud_num; k++)
{
if(temp_marks < s[k].marksreturn())
{
temp_marks = s[k].marksreturn();
loc = k;
}
}
cout<<s[loc].name<<" Has the highest marks";
return 0;
}