-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure2.cpp
More file actions
71 lines (62 loc) · 1.62 KB
/
structure2.cpp
File metadata and controls
71 lines (62 loc) · 1.62 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
#include <iostream>
using namespace std;
struct Person
{
char name[50];
int roll;
int marks[5];
int sum = 0;
float percentage;
};
int main()
{
int n, j, marks;
cout << "enter limit" << endl;
cin >> n;
Person p1[50];
int i;
for (j = 0; j < n; j++)
{
cout << "Enter Full name: ";
cin >> p1[j].name;
cout << "Enter roll ";
cin >> p1[j].roll;
for (i = 0; i < 5; i++)
{
cout << "Enter marks: ";
cin >> p1[j].marks[i];
p1[j].sum = p1[j].sum + p1[j].marks[i];
p1[j].percentage = p1[j].sum * 0.4;
}
}
cout << "\nDisplaying Information." << endl;
for (j = 0; j < n; j++)
{
cout << "Name: " << p1[j].name << "\n";
cout << "roll: " << p1[j].roll << '\n';
for (i = 0; i < 5; i++)
{
cout << "marks: " << p1[j].marks[i] << endl;
cout << "\n\n";
}
cout << "sum" << p1[j].sum << endl;
cout << "percentage" << p1[j].percentage << endl;
}
int in;
cout << "enter roll number to search" << endl;
cin >> in;
for (j = 0; j < n; j++)
{
if (p1[j].roll == in)
cout << "Name: " << p1[j].name << "\n";
cout << "roll: " << p1[j].roll << '\n';
for (i = 0; i < 5; i++)
{
cout << "marks: " << p1[j].marks[i] << endl;
cout << "\n\n";
}
cout << "sum" << p1[j].sum << endl;
cout << "percentage" << p1[j].percentage << endl;
}
return 0;
}