Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
vector myvector (5);
7.
int* p = myvector.data();
8.
*p = 10;
9.
++p;
10.
*p = 20;
11.
p[2] = 100;
12.
for (unsigned i = 0; i < myvector.size(); ++i)
13.
cout
Options:
A .  10 20 0 100 0
B .  10 20 0 100
C .  10 20 0
D .  10 20
Answer: Option A

In this program, We are allocating the values to the vector and unallocated values are left as zero.
Output:
$ g++ vect4.cpp
$ a.out
10 20 0 100 0



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers