What will be the capacity of vector at the end in the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
v.reserve(50);
cout<<v.capacity();
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
v.reserve(50);
cout<<v.capacity();
return 0;
}A. 10
B. 8
C. 50
D. 60
Answer: Option C

Join The Discussion