In: Computer Science
If you have any doubts, please give me comment...
#include<iostream>
#include<vector>
using namespace std;
void input(vector<int> &v){
cout<<"Enter 10 values: ";
int val;
for(int i=0; i<10; i++){
cin>>val;
v.push_back(val);
}
}
int main(){
vector<int> v;
input(v);
cout<<"The entered vector data is:";
for(int i=0; i<v.size(); i++){
cout<<" "<<v[i];
}
cout<<"\n\nThe second element is: "<<v[1]<<endl;
v[0] = v[1];
v[2] = v[1];
v[7] = v[1];
v[8] = v[1];
cout<<"\n\nAfter replacing with second element, the vector is:"<<endl;
for(int i=0; i<v.size(); i++){
cout<<v[i]<<" ";
}
cout<<endl;
return 0;
}