-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathVECTOR_basic.cpp
More file actions
24 lines (22 loc) · 817 Bytes
/
VECTOR_basic.cpp
File metadata and controls
24 lines (22 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <bits/algorithmfwd.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v;
int i;
cout<<"Vector_SIZE_original/initial:"<<v.size()<<endl;//initially the size of vector is =? FIND OUT.
for(int i=0;i<5;i++)
{
v.push_back(i);//push back function is used to insert elements into vector
}
cout<<"Vector_SIZE_EXTENDED:"<<v.size()<<endl;//Vectors differ from array on that they are dynamically sized so here it is to be seen size of vector changes to no. of values inputted.
vector<int>::iterator c= v.begin();//an iterator, moving/iterating over the vector from begining to the end of the vector to show the values stored in it.
while(c!=v.end())
{
cout<<"value of v="<< *c<<endl;
c++;
}
return 0;
}