C++ Program to implement the use of STL vector :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
// Similar to array but useful when the number of elements (size) is unknown... | |
using namespace std; | |
int main() | |
{ | |
vector<int>v; | |
int t; | |
cout<<"Enter the numbers ( Number 6 to terminate ) "; | |
while(1){ | |
cin>>t; | |
if(t==6)break; | |
v.push_back(t); | |
} | |
cout<<"\nThe entered numbers are.."; | |
for(int i=0;i<v.size();i++){ | |
cout<<v[i]<<" "; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment