Skip to main content
C++ Output Prediction Easy +10 XP

Vector Size

What does this output?

C++Read-only
vector<int> v = {1, 2, 3, 4};
cout << v.size();

What is the output?

Show answer and explanation

Answer: 4

The size() method returns the number of elements in the vector, which is 4.

Hint: Count the elements.

What this challenge tests

Output Prediction in C++: vectors, stl.

Related challenges