1.This question may have 0 to multiple answers. Choose all that apply. Consider the following for loop:
for (int x = 1; x < 5; increment) { cout << x + 1 << endl; }
If the last value printed is 5, which of the following might have been used for increment?
2.If a dowhile structure is used:
A | Counter-controlled iteration is not possible. |
B | An infinite loop cannot take place. |
C | An off-by-one error cannot occur. |
D | The body of the loop will execute at least once. |
3.In C++, the condition (4 > y > 1):
A | Does not evaluate correctly and should be replaced by (4 > y && y > 1). |
B | Evaluates correctly and could be replaced by (4 > y && y > 1). |
C | Does not evaluate correctly and should NOT be replaced by (4 > y && y > 1). |
D | Evaluates correctly and could NOT be replaced by (4 > y && y > 1). |
4.Which of the following initializes a vector with a list initializer:
A | vector integers{1, 2, 3, 4, 5, 6}; |
B | vector integers(1, 2, 3, 4, 5, 6); |
C | vector integers{1, 2, 3, 4, 5, 6}; |
5.This question may have 0 to multiple answers. Choose all that apply. Assuming var is an int:
A | var++ adds 1 to var, returning the new var before the semicolon. |
B | ++var adds 1 to var, returning the new var before the semicolon. |
C | var++ adds 1 to var, returning the old var before the semicolon. |
D | ++var adds 1 to var, returning the old var before the semicolon. |
6.This question may have 0 to multiple answers. Choose all that apply. Which of the following is a valid way to retrieve the length of a C++ string, str?
7.An array is a sequence of objects allocated in contiguous memory. That is, all elements of an array can be of different types and there are no gaps between them in the sequence.
8.The following statements compile in C++:
int arr[10]; arr[-1] = 1; arr[10] = 2;
9.The support for C-style strings are in
10.What is the length of the resulting C-style string, str, after strcpy()?
char str[100]; strcpy(str, "C++");
11.C++ style string is terminated by '\0'.
12.Assuming str is an non-empty C-style string, is the following True or False?
sizeof(str) == strlen(str);
13. If the variable x has the original value of 3.3, what is the output value after the following?
cout << static_cast(x);
14. What is the value returned by the following function?
int function() { int value = 30; return value + 5; value += 10; }
............
15.Assert terminates the program with a message when its boolean argument turns out to be TRUE.
16. Multiple arguments to a function are separated by a
17 The functions pow(), sqrt(), and fabs() are found in which include file?
18.This question may have 0 to multiple answers. Choose all that apply. How do you concatenate two C++ strings, str1 and str2?
B | strconcate(str1, str2); |