-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.cpp
More file actions
49 lines (44 loc) · 1.11 KB
/
vector.cpp
File metadata and controls
49 lines (44 loc) · 1.11 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
#include <iostream>
#include <vector>
using namespace std;
struct Student {
int roll;
char section;
};
void newFunction();
int main(int argc, char *argv[]) {
cout << "Hello World" << "\n";
vector<int> myVector;
int inputNumber;
int counter = 0;
while(inputNumber != -1) {
cout << ++counter << " => ";
cin >> inputNumber;
myVector.push_back(inputNumber);
}
for (int i = 0; i < myVector.size(); ++i) {
cout << myVector[i] << " ";
}
cout << "\n" << myVector.size() << "\n\n";
newFunction();
return 0;
}
void newFunction() {
int inputNumber;
vector<Student> newVector;
Student S;
int counter=0;
while(inputNumber != -1) {
cout << ++counter << " ROLL NUMBER => ";
cin >> S.roll;
cout << counter << " SECTION => ";
cin >> S.section;
newVector.push_back(S);
cout << "\n-1 to exit any other to continue...\n";
cin >> inputNumber;
}
for(int i = 0; i < newVector.size(); i++) {
cout << newVector[i].roll << " " << newVector[i].section;
cout << "\n";
}
}