C++20 sections · 1024 units
Open in CourseQuiz: Vector Problems
Test your understanding
Check Your Understanding
To find the sum of a vector, what's the best loop approach?
- A.for (int i = 1; i <= v.size(); i++)
- B.for (int num : v) sum += num;
- C.while (v.size() > 0) sum += v.pop_back();
- D.for (int i = 0; i < v.capacity(); i++)