A | Default statement is missing. |
B | There is an error in Line 2 |
C | Strings cannot be used with switch statement. |
D | Semi colon is missing at the end of the switch statement. |
4.What is stored in the variable name result?
string str1= John Smith; string str2 = John Doe; bool result = (str11 < str2);
5.In a brief sentence describe what is wrong with the following code:
1 int minval(int arr[], int size) 2 { 3 int localmin; 4 for (int i=0; i
6.After the following code snippet is pre-processed, the statement in Line 5 expands to which of the following:
1 # See rand() in http://www.cplusplus.com/reference/cstdlib/rand/ 2 #include 3 4 #define R(n) random()%n 5 int value = R(j-i+1);
A | int value = rand()%j-i+1; |
B | int value = random()%j-i+1; |
C | int value = R(j-i+1)%j-i+1; |
7.We have the following 2 char arrays with identical character sequences in them. The easiest way to compare if both arrays have the same content is to check for the result of arr1==arr2.
char arr1[] = {'p', 'c', 'c'}; char arr2[] = {'p', 'c', 'c'};
8.We can copy str1 into str2 by the following:
char str1[10] = "PCC"; char str2[10]; strcpy(str1, str2);
9.This question may have 0 to multiple answers. Choose all that apply. Examine the following code and identify the Line number(s) where a bug may exist.
1 char str[4]; 2 for (i=0; i<3; i++) 3 str[i]=getchar(); 4 cout << str;
10. The following code is CORRECT:
char str[3] = "pcc"; int i;
11. Generally, we DON'T need to write error handlers (namely, functions that are designed to catch input, functional, or output errors) for errors caught at compile time.
12.This question may have 0 to multiple answers. Choose all that apply. Which of the following is TRUE about a function:
A | Passing lots of arguments into a function is costly compared to alternatives. |
B | Having too many function calls in a program slows it down. |
C | A function declaration tells the compiler about a function's name, return type, and parameters. |
D | A function can return AT MOST 1 value back to its caller. |
13.When passing an array into a function, we must also pass in the array's size into the function.
14. This question may have 0 to multiple answers. Choose all that apply. Converting from data type _______ to data type ______ will result in the loss of data.
15. A data type that can have values ONLY between the range 0 to 65535 is a:
16. 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); |
17. Based on the Problem Description, we need to keep the character count for every one of the 128 possible characters. Which of the following statements illustrates the use of arr (array created from the last problem) to increment the ASCII_CHARACTER count by 1? ASCII_CHARACTER can be any one of the first 128 characters in the ASCII Table (Links to an external site.)Links to an external site. (not the Extended ASCII Table).
A | arr[ASCII_CHARACTER-97]++; |
B | arr[ASCII_CHARACTER] = ASCII_CHARACTER++; |
C | arr[ASCII_CHARACTER]++; |
D | arr[ASCII_CHARACTER-65]++; |
18. Based on the Problem Description, the input may be the combination of any one of the 128 characters in the ASCII table (Links to an external site.)Links to an external site.. Write a STATEMENT (not the entire program) to create/instantiate an array of 128 characters called arr.