-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum.cpp
More file actions
79 lines (61 loc) · 1.43 KB
/
sum.cpp
File metadata and controls
79 lines (61 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
using namespace std;
#define MAX 10
class student
{
private : char name[30];
int rollNo;
float perc;
int marks[100];
int i;
float sum;
public :
void
getDetails(void);
void putDetails(void);
};
void student::getDetails(void)
{
cout << "Enter name: ";
cin >> name;
cout << "Enter roll number: ";
cin >> rollNo;
for (i = 0; i < 10; i++)
{
cout << "Enter marks: ";
cin >> marks[i];
sum = sum + marks[i];
perc = sum / 500 * 100;
}
}
void student::putDetails(void)
{
cout << "Student details:\n";
cout << "Name:" << name << ",Roll Number:" << rollNo ;
for (i = 0; i < 10; i++)
{
cout << "marks: " << marks[i] << endl;
cout << "\n\n";
}
cout << "sum" << sum << endl;
cout << "percentage" << perc << endl;
}
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;
}