-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.cpp
More file actions
62 lines (48 loc) · 1.13 KB
/
class.cpp
File metadata and controls
62 lines (48 loc) · 1.13 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
#include <iostream>
using namespace std;
#define MAX 10
class student
{
private : char name[30];
int rollNo;
int total;
float perc;
public :
void
getDetails(void);
void putDetails(void);
};
void student::getDetails(void)
{
cout << "Enter name: ";
cin >> name;
cout << "Enter roll number: ";
cin >> rollNo;
cout << "Enter total marks outof 500: ";
cin >> total;
perc = (float)total / 500 * 100;
}
void student::putDetails(void)
{
cout << "Student details:\n";
cout << "Name:" << name << ",Roll Number:" << rollNo << ",Total:" << total << ",Percentage:" << perc;
}
int main()
{
student std[MAX];
int n, loop;
cout << "Enter total number of students: ";
cin >> n;
for (loop = 0; loop < n; loop++)
{
cout << "Enter details of student " << loop + 1 << ":\n";
std[loop].getDetails();
}
cout << endl;
for (loop = 0; loop < n; loop++)
{
cout << "Details of student " << (loop + 1) << ":\n";
std[loop].putDetails();
}
return 0;
}