Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

What is the output of the program mentioned in the description? -

  Shared By: Nathan Bouchard    Date: Oct 10    Category: C++ Programming    Views: 1105

Answer:

Consider the following code snippet:
int main()
{
vector <int> v1(10);
vector <int> v2(10);
v1.at(0)=24;
v1.at(1)=20;
v1.at(2)=38;
for(int i=0;i <3; i++)
{
cout<<v1[i]<<" ";
}
v2=v1;
cout<<v2[0];
return 0;
}

What is the output of the above program?

Options

a) Error as vectors cannot be copied
b) 24 20 38 24
c) 24 20 38
d) No output

Answer : b) 24 20 38 24

Share: 
 



Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: