Question 6
Back to Exercise
What is the output of the following C++ program on a 64-bit system?
#include <iostream>
#include <vector>
int main() {
std::vector<int> v{1, 2, 3};
v.resize(5, 9);
v.resize(4);
for (int x : v) std::cout << x;
std::cout << ' ' << v.size() << '\n';
return 0;
}
- A 1239 4 Correct
- B 12399 5
- C 1230 4
- D 1299 4
Correct Answer: Option A
resize(5, 9) appends two 9s; resize(4) drops the last one.
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!