
C++ Vectors Review
Authored by Ferhat Travaci
Computers
9th - 12th Grade
Used 13+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
16 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements is true about vectors?
Vectors allow you to store multiple values in a single variable
Vectors can only hold one type of value
Vectors are dynamic and can grow in size
All of the other options are true
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is NOT a correct way to create a vector?
vector<string> greeting {"Hello", "Hola"};
vector<int> nums {3, 6, 7.8, 9};
vector<bool> option {true};
All of the options are correct
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be printed from the following code snippet?
vector<string> count {"One", "Two", "Three"};
cout << count.at(1) << endl;
cout << count[2] << endl;
1
2
One
Two
Two
Three
Three
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which statement best describes the actions of the push_back command?
push_back adds a new element to the front of the vector, pushing all of the elements back 1 index and increasing the overall size by 1.
push_back adds a new element to the end of the vector, increasing the size by 1.
push_back replaces the first element in the vector.
push_back replaces the last element in the vector.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code segment return?
vector<string> lang {"C++", "Java", "Python", "JavaScript"};
cout << lang.at(lang.size() - 2) << endl;
C++
Java
Python
JavaScript
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will print from the following code snippet?
vector<double> constants {3.14, 2.718, 0.577};
constants.pop_back();
constants.push_back(constants.size());
cout << constants[2] << endl;
2
3
2.718
0.577
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following code segments will print all members of an int vector v?
1 only
2 only
Neither 1 or 2
Both 1 and 2
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?