-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_1_ParallelArrays.cpp
More file actions
63 lines (62 loc) · 1.46 KB
/
Copy pathExample_1_ParallelArrays.cpp
File metadata and controls
63 lines (62 loc) · 1.46 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
#include <iostream>
using namespace std;
const int length = 5;
string name[length]; // store student name
int roll_no[length]; // store student roll number
float gpa[length]; // store student gpa
// prototype
void store(); // store user enter values
void display(); // dispay user enter values
int main()
{
int option = -1;
while (option != 3)
{
cout << "Press 1 to store data " << endl;
cout << "Press 2 to view data" << endl;
cout << "Press 0 to Exit ...";
cin >> option;
if (option == 0)
{
break;
}
else if (option == 1)
{
store();
}
else if (option == 2)
{
display();
}
else
{
break;
}
}
} // end of main
// definition
void store()
{
for (int i = 0; i < length; i++)
{
cout << "Enter student name : ";
cin >> name[i];
cout << "Enter student roll number : ";
cin >> roll_no[i];
cout << "Enter GPA : ";
cin >> gpa[i];
cout << "------------------" << endl;
}
} // end of store function
void display()
{
cout << "Roll number "
<< "\t"
<< "Name "
<< "\t"
<< "GPA" << endl;
for (int i = 0; i < length; i++)
{
cout << roll_no[i] << "\t\t" << name[i] << "\t" << gpa[i] << endl;
}
} // end of display function