Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

16. Write the code to add the new element \"candy\" to the end of a vector of st

ID: 3535978 • Letter: 1

Question

16. Write the code to add the new element "candy" to the end of a vector of strings named "delights." (Points : 2) 1. Look at the following code example:

int num1 = 10;
int num2 = 15;
int answer = num1 % num2;

What is the value of answer after the code is executed? (Points : 1) 0
.6666666666666667
10
15

2. What will the value of "phrase" be after this code is executed? string phrase = "Good " + "Try"; (Points : 1) Good
Try
GoodTry
Good Try

3. Given the following code:



What will print out on the console? (Points : 1) you
do
this
test

4. Which of the following statements is equivalent to: score +=100;? (Points : 1) x = score + 100;
score = score + 100
if score = 100 ...
score = score + 100;

5. If you wanted to code an array that would display characteristics for characters in a given world, nation, and clan; which of the following is correct? (Points : 1) string world [15];
string nation[100];
string clan [10];
string chariArray[15],[100],[10];
string chariArray[15][100][10];
none of the above

6. Which type of looping structure is best suited for "The Game Loop?" (Points : 1) do
while
for
loopty

7. Given the following code:

string myPhrase = "Have a beautiful day!"

Which of the following references is NOT valid? (Points : 1) myPhrase[0]
myPhrase[10]
myPhrase[20]
myPhrase[25]

8. Fill in the blank. ++lives; is a demonstration of a __________ operator. (Points : 1) incremental
increment
decremental
decrement

9. What is the correct way to define an integer variable named "pause?" (Points : 1) integer pause
int pause
int pause;
integer pause;

10. Which of the following is NOT a valid variable name? (Points : 1) 1stGrade
Grade1
gradeOne
grade1

11. Which array search is the most efficient? (Points : 1) binary
integer
linear
string

12. What is the purpose of the STL? (Points : 1) To provide lazy programmers a job
It is the Superior Tangential Limiting tool for arrays.
To Provide access to powerful programming tools
To bring the power of teamwork together in programming (Simple Teamwork Library)

13. Which of the following is NOT an STL container? (Points : 1) array
algorithms
iterators
vectors

14. Which of the following is known as a dynamic array? (Points : 1) algorithm
multi-dimensional array
multi-tonal array
vector

15. Which of the following declares a vector consisting of integers, named population? (Points : 1) #define <vector> integer population;
#include <vector> integer population;
vector <integer> population;
vector <int> population;

16. Write the code to add the new element "candy" to the end of a vector of strings named "delights." (Points : 2)
17. If you had a vector containing "popcorn," "peanuts," and "cotton candy," what would the size() member function return? (Points : 1) 0
1
2
3

18. Which of the following would add "window" to the end of the "building" vector? Assume that the "building" vector already contains five elements. (Points : 1) building[4] = "window";
building[5] = "window";
building.size()
building.push_back("window");

19. Which of the following removes the last element of a vector? (Points : 1) clear()
clear(last)
empty()
pop_back()

20. After the following code executes, what will the value of classes[1] be?

(Points : 1) Visual Basic
C++
Alice
Innovations
None of the above, you can't access a vector using [].

21. After the following code executes, what will the value of classes[3] be?

(Points : 1) Innovations
Flash
Alice
This code would throw an error.

22. After the following code is executed, what will the value of classes[4] be?

(Points : 1) Innovations
Flash
This code causes a complier error.
This code causes a run-time error.

23. In vector processing, how does myvector.size() differ from myvector.capacity()? (Points : 1) There is no difference. Both statements will return the same value.
myvector.size() is used for arrays, and myvector.capacity is used for vectors
myvector.size() returns the current number of elements in the vector while myvector.capacity() returns the amount of space left before memory reallocation
There is no such thing as the capacity() member function.

24. Given the follwing code that will loop through a vector with iter defined as a const_iterator:



What is the correct statement that needs to be coded next in order to print out the contents of the vector? (Points : 1)


{

25. Given the following code:




What will print on the output console? (Points : 1) Nothing.
Nothing. Code is invalid.
Found it.
Where did it go?

26. Given the following code:




Which of the following will place the weather vector in a random order?

(Points : 1) seq_shuffle(weather.begin(), weather.end());
random_shuffle(weather.begin(), weather.end());
randomly_shuffle(weather.begin(), weather.end());
You cannot sort vectores randomly.

27. Which of the following is NOT a valid algorithm> (Points : 1) find()
random()
random_shuffle()
sort()

28. Let's say you have a vector defined, and it contains 10 elements. What statement will change the vector capacity to 35, once it has already been defined? (Points : 1) myVector.capacity(35);
myVector.reserve(35);
myVector.size(35);
myVector.updatesize=35;

29. Fill in the blanks:

Adding to or deleting from the end of a vector is very efficient. To add a record at another place, use the _____ member function. To delete a record at a place other than the end, use the _____ member function. (Points : 1) add, delete
insert, delete
insert, erase
add, erase

30. Which of the following is NOT a valid STL Container? (Points : 1) list
map
queue
stacker

31. Fill in the blank.

_____________ is a process that helps code the logic of the program where each pass gets more detailed. (Points : 1) stepwise refinement
pseudocode
flowcharting
agile and scrum

32. Fill in the blanks.

A function returns a _____ of a given type. If it doesn't need to return a value, you need to place _____ instead of a variable type in the function declaration. (Points : 1) field, forget
variable, void
base, omit
value, void

33. Which of the following is a valid function prototype? (Points : 1) int FindValue(num1, num2, num3);
int FindValue(int num1 = 0, int num2= 0, int num3);
int FindValue(int num1, int num2, int num3);
int FindValue(void);

34. Function prototypes are NOT required when using a function. (Points : 1) True
False

35. How would you CALL a function that was named "translate" and required two string parameters? (Points : 1) translate();
translate(string "One", string "Two:)
translate(string "One", string "Two:);
translate(one, two);

36.


What is the scope of a variable? (Points : 1) another word for "refresh"
where the variable can be seen in your program
a code versioning system used to speed up variable development
What are you talking about? Scope is only a mouthwash!

37. Given the following code:




What is the value displayed to the console? (Points : 1) 1
2
3
Impossible to tell -- not enough information

38. What is the process called when you allow a function to accept multiple sets of arguments? (Points : 1) argumentative
functional
overridable
overloading

39. What is the main purpose of function inlining? (Points : 1) avoid having to jump to the function code everytime it is called
speed up the compiler
utilize 64-bit systems
to prepare the program to split between header and implementation classes

40. What is the purpose of classes? (Points : 1) to implement OOP in C++
to extend the C++ language
to confuse the general public
job security

41. How do you define a class named Graduation (Points : 1) Graduation Class
Class Graduation
graduation class
class Graduation

42. What is it called when you crate an object from a class? (Points : 1) birth
creation
encapsulation
instantiation

43. What is the purpose of a constructor in a class definition? (Points : 1) to initialize some data members
to build the class within the program
to preceed the int main() function with a class
there is no such thing as a constructor

44. What is the purpose of a class encapsulator? (Points : 1) encapsulation
class definition
it is a springboard to stepwise refinement
there is no such thing as a class encapsulator

45. Fill in the blank.

Member acces is _____ by default. (Points : 1) classless
private
public
void

46. What is NOT a purpose of a constant member function? (Points : 1) to remain constant
it can't modify a data member of its class
it keeps you from altering a data member accidentally
it makes your intentions clear to other programmers

47. What is the purpose of a static data member? (Points : 1) it changes each time the class is run
it retains the value in the class
it is a tightly scoped variable
it is an efficient means of error detection

48. Fill in the blank,

The ultimate goal when using classes is to create seperate _____ and _____ files to hold class information. (Points : 1) prototype, definition
header, implementation
source code, object code
translated, compiled

49. What preprocessor compiler directive is used to prevent multiple definitions when using seperate class files? (Points : 1) #ifndef
#include <class>
#include <ifndef>
#include <directive>

50. Fill in the blanks:

It is a general rule to make data members _____ and methods _____. (Points : 1) private, private
public, public
private, public
public, private

Explanation / Answer

1)10

2)GoodTry

3)can't see

4)score = score+100

5)string chariArray[15][100][10];

6)for

7) myPhrase[0]

8) increment

9)int pause;

10)1stGrade

11)binary

12) To Provide access to powerful programming tools

13)algorithms

14)multi-dimensional array

15)vector <integer> population;

16)"delights"^"candy"

17)3

18) building[5] = "window";

19)clear(last)

20)-22),24)-26)can't see

23) myvector.size() returns the current number of elements in the vector while myvector.capacity() returns the amount of space left before memory reallocation

27)random_shuffle()

28)myVector.updatesize=35;

29) insert, delete

30)map

31)-50)can't see

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote