LearnFrenzy
Sign in Take a free test

Arrays and Vectors · Arrays and Vectors MCQ · Question 8

size() vs capacity() of a vector Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What does capacity() of a vector report?

  • A The number of elements
  • B How many elements fit in the allocated storage before a reallocation is needed Correct
  • C The maximum possible size
  • D The size in bytes
Correct Answer: Option B

capacity ≥ size always. size counts elements actually stored.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links