Computer Scientists are Pretty Pessimistic

Tuesday 1 March 2016

Use of Vector in C++

#include <iostream>
#include <vector>
using namespace std;
int main ()
{
    vector<int>t;
    int val,i,n;
    cout<<"Array Elements: ";
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>val;
        t.push_back(val);
    }
    for(i=0;i<10;i++)
        cout<<t[i]<<endl;

    return 0;
}

No comments:

Post a Comment