Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Question 1 (1 point)
- Question 1 Unsaved
- A function ________ eliminates the need to place a function definition before all calls to the function.
- Question 1 options:
- A) header
- B) prototype
- C) parameter
- D) argument
- E) None of these
- Save
- Question 2 (1 point)
- Question 2 Unsaved
- If a function does not have a prototype, default arguments may be specified in the function ________.
- Question 2 options:
- A) execution
- B) return type
- C) call
- D) header
- E) None of these
- Save
- Question 3 (1 point)
- Question 3 Unsaved
- This is a collection of statements that performs a specific task.
- Question 3 options:
- A) infinite loop
- B) constant
- C) function
- D) variable
- E) None of these
- Save
- Question 4 (1 point)
- Question 4 Unsaved
- This is a dummy function that is called instead of the actual function it represents.
- Question 4 options:
- A) main function
- B) driver
- C) overloaded function
- D) stub
- Save
- Question 5 (1 point)
- Question 5 Unsaved
- Look at the following function prototype.
- int myFunction(double);
- What is the data type of the function's return value?
- Question 5 options:
- A) void
- B) int
- C) double
- D) Can't tell from the prototype
- Question 6 (1 point)
- Question 6 Unsaved
- A function is executed when it is:
- Question 6 options:
- A) prototyped
- B) called
- C) declared
- D) defined
- E) None of these
- Save
- Question 7 (1 point)
- Question 7 Unsaved
- When used as parameters, these types of variables allow a function to access the parameter's original argument.
- Question 7 options:
- A) floating-point
- B) undeclared
- C) counter
- D) reference
- E) None of these
- Save
- Question 8 (1 point)
- Question 8 Unsaved
- These types of arguments are passed to parameters automatically if no argument is provided in the function call.
- Question 8 options:
- A) Relational
- B) Local
- C) Default
- D) Global
- E) None of these
- Save
- Question 9 (1 point)
- Question 9 Unsaved
- Which line in the following program contains a call to the showDub function?
- 1 #include
- 2 using namespace std;
- 3
- 4 void showDub(int);
- 5
- 6 int main()
- 7 {
- 8 int x = 2;
- 9
- 10 showDub(x);
- 11 cout << x << endl;
- 12 return 0;
- 13 }
- 14
- 15 void showDub(int num)
- 16 {
- 17 cout << (num * 2) << endl;
- 18 }
- Question 9 options:
- A) 4
- B) 6
- C) 10
- D) 15
- Save
- Question 10 (1 point)
- Question 10 Unsaved
- Look at the following function prototype.
- int myFunction(double, double, double);
- How many parameter variables does this function have?
- Question 10 options:
- A) 1
- B) 2
- C) 3
- D) Can't tell from the prototype
- Question 11 (1 point)
- Question 11 Unsaved
- It is a good programming practice to ________ your functions by writing comments that describe what they do.
- Question 11 options:
- A) prototype
- B) eliminate
- C) document
- D) execute
- E) None of these
- Save
- Question 12 (1 point)
- Question 12 Unsaved
- A ________ variable is declared outside all functions.
- Question 12 options:
- A) local
- B) counter
- C) global
- D) floating-point
- E) None of these
- Save
- Question 13 (1 point)
- Question 13 Unsaved
- A function can have zero to many parameters, and it can return this many values.
- Question 13 options:
- A) no
- B) zero to many
- C) a maximum of ten
- D) only one
- E) None of these
- Save
- Question 14 (1 point)
- Question 14 Unsaved
- What is the output of the following program?
- #include
- using namespace std;
- void doSomething(int&);
- int main()
- {
- int x = 2;
- cout << x << endl;
- doSomething(x);
- cout << x << endl;
- return 0;
- }
- void doSomething(int& num)
- {
- num = 0;
- cout << num << endl;
- }
- Question 14 options:
- A) 2
- 2
- 2
- B) 2
- 0
- 2
- C) 2
- 0
- 0
- D) 0
- 0
- 0
- Save
- Question 15 (1 point)
- Question 15 Unsaved
- This vector function removes an item from a vector.
- Question 15 options:
- A) pop_back
- B) remove_item
- C) erase
- D) delete_item
- Question 16 (1 point)
- Question 16 Unsaved
- A two-dimensional array can have elements of ________ data type(s).
- Question 16 options:
- A) one
- B) four
- C) two
- D) Any of these
- E) None of these
- Save
- Question 17 (1 point)
- Question 17 Unsaved
- Which statement correctly defines a vector object for holding integers?
- Question 17 options:
- A)
- vector <int> v;
- B)
- int vector v;
- C)
- vector v <int>;
- D)
- int <vector> v;
- Save
- Question 18 (1 point)
- Question 18 Unsaved
- What is the last legal subscript that can be used with the following array?
- int values[5];
- Question 18 options:
- A) 5
- B) 4
- C) 6
- D) 0
- Save
- Question 19 (1 point)
- Question 19 Unsaved
- The statement:
- int grades[ ] = { 100, 90, 99, 80};
- shows an example of:
- Question 19 options:
- A) implicit array sizing
- B) default arguments
- C) an illegal array declaration
- D) an illegal array initialization
- E) None of these
- Save
- Question 20 (1 point)
- Question 20 Unsaved
- What will the following C++ 11 code display?
- vector<int> numbers { 3, 5 };
- for (int val : numbers)
- cout << val << endl;
- Question 20 options:
- A)
- 3
- 5
- B)
- 5
- 5
- 5
- C)
- 3
- 3
- 3
- 3
- 3
- D)
- Nothing. This code has an error.
- Question 21 (1 point)
- Question 21 Unsaved
- How many elements does the following array have?
- int bugs[1000];
- Question 21 options:
- A) 999
- B) 1001
- C) 1000
- D) Cannot tell from the code
- Save
- Question 22 (1 point)
- Question 22 Unsaved
- Which of the following is a valid C++ array definition?
- Question 22 options:
- A) float $payments[10];
- B) void numbers[5];
- C) int array[10];
- D) int array[0];
- E) None of these
- Save
- Question 23 (1 point)
- Question 23 Unsaved
- It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3].
- Question 23 options:
- A) legal in C++
- B) not good programming practice
- C) illegal in C++
- D) not recommended by the ANSI committee
- E) None of these
- Save
- Question 24 (1 point)
- Question 24 Unsaved
- To access an array element, use the array name and the element's ________.
- Question 24 options:
- A) data type
- B) name
- C) subscript
- D) value
- E) None of these
- Save
- Question 25 (1 point)
- Question 25 Unsaved
- By using the same ________ you can build relationships between data stored in two or more arrays.
- Question 25 options:
- A) data
- B) array name
- C) arguments
- D) subscript
- E) None of these
- Question 26 (1 point)
- Question 26 Unsaved
- A two-dimensional array of characters can contain ________.
- Question 26 options:
- A) strings of different lengths
- B) uninitialized elements
- C) strings of the same length
- D) All of these
- E) None of these
- Save
- Question 27 (1 point)
- Question 27 Unsaved
- This vector function is used to insert an item into a vector.
- Question 27 options:
- A) store
- B) add_item
- C) push_back
- D) insert_item
- Save
- Question 28 (1 point)
- Question 28 Unsaved
- What will the following code do?
- const int SIZE = 5;
- double x[SIZE];
- for(int i = 2; i <= SIZE; i++)
- {
- x[i] = 0.0;
- }
- Question 28 options:
- A) Each element in the array, except the first, is initialized to 0.0
- B) Each element in the array is initialized to 0.0
- C) Each element in the array, except the first and the last, is initialized to 0.0
- D) An error will occur when the code runs
- Save
- Question 29 (1 point)
- Question 29 Unsaved
- Array elements must be ________ before a binary search can be performed.
- Question 29 options:
- A) sorted
- B) positive numbers
- C) set to zero
- D) summed
- E) None of these
- Save
- Question 30 (1 point)
- Question 30 Unsaved
- A(n) ________ search is more efficient than a ________ search.
- Question 30 options:
- A) integer, double
- B) binary, linear
- C) linear, binary
- D) character, string
- E) None of these
- Question 31 (1 point)
- Question 31 Unsaved
- Using a linear search to find a value that is stored in the last element of an array of 20,000 elements, ________ element(s) must be compared.
- Question 31 options:
- A) only half
- B) 20,000
- C) 2000
- D) only the first
- E) None of these
- Save
- Question 32 (1 point)
- Question 32 Unsaved
- The ________ is adequate for searching through small arrays.
- Question 32 options:
- A) linear search
- B) unary search
- C) bubble sort
- D) binary search
- E) None of these
- Save
- Question 33 (1 point)
- Question 33 Unsaved
- A binary search begins with the ________ element of an array.
- Question 33 options:
- A) last
- B) middle
- C) first
- D) largest
- E) None of these
- Save
- Question 34 (1 point)
- Question 34 Unsaved
- The following statement:
- cin >> *num3;
- Question 34 options:
- A) is illegal in C++
- B) stores the keyboard input into the pointer called num3
- C) stores the keyboard input into the variable num3
- D) stores the keyboard input into the variable pointed to by num3
- E) None of these
- Save
- Question 35 (1 point)
- Question 35 Unsaved
- What will the following code output?
- int number = 22;
- int *var = &number;
- cout << var << endl;
- Question 35 options:
- A) An asterisk followed by the address of the number variable
- B) 22
- C) An asterisk followed by 22
- D) The address of the number variable
- Question 36 (1 point)
- Question 36 Unsaved
- Look at the following statement:
- sum += *array++;
- This statement ________.
- Question 36 options:
- A) will always result in a compiler error
- B) increments the dereferenced pointer's value by one, then assigns that value
- C) assigns the dereferenced pointer's value, then increments the pointer's address
- D) is illegal in C++
- E) None of these
- Save
- Question 37 (1 point)
- Question 37 Unsaved
- If a variable uses more than one byte of memory, for pointer purposes its address is ________.
- Question 37 options:
- A) the address of the first byte of storage
- B) general delivery
- C) the average of the addresses used to store the variable
- D) the address of the last byte of storage
- E) None of these
- Save
- Question 38 (1 point)
- Question 38 Unsaved
- A function may return a pointer, but the programmer must ensure that the pointer ________.
- Question 38 options:
- A) has not been assigned an address
- B) was received as a parameter by the function
- C) still points to a valid object after the function ends
- D) has not previously been returned by another function
- E) None of these
- Save
- Question 39 (1 point)
- Question 39 Unsaved
- In C++ 11, the ________ key word was introduced to represent the address 0.
- Question 39 options:
- A) nullptr
- B) weak_ptr
- C) NULL
- D) All of these
- E) None of these
- Save
- Question 40 (1 point)
- Question 40 Unsaved
- The ________, also known as the address operator, returns the memory address of a variable.
- Question 40 options:
- A) asterisk ( * )
- B) exclamation point ( ! )
- C) percent sign (%)
- D) ampersand ( & )
- E) None of these
- Question 41 (1 point)
- Question 41 Unsaved
- What will the following code output?
- int number = 22;
- int *var = &number;
- cout << *var << endl;
- Question 41 options:
- A) An asterisk followed by 22
- B) 22
- C) The address of the number variable
- D) An asterisk followed by the address of the number variable
- Save
- Question 42 (1 point)
- Question 42 Unsaved
- A pointer variable may be initialized with ________.
- Question 42 options:
- A) any non-zero integer value
- B) a valid address in the computer's memory
- C) an address less than 0
- D) A and C only
- E) None of these
- Save
- Question 43 (1 point)
- Question 43 Unsaved
- ________ can be used as pointers.
- Question 43 options:
- A) Numeric constants
- B) Punctuation marks
- C) Array names
- D) All of these
- E) None of these
- Save
- Question 44 (1 point)
- Question 44 Unsaved
- Which of the following statements is not valid C++ code?
- Question 44 options:
- A) float num1 = &ptr2;
- B) int ptr = int *num1;
- C) int ptr = &num1;
- D) All of these are valid.
- E) All of these are invalid.
- Save
- Question 45 (1 point)
- Question 45 Unsaved
- When the less than ( < ) operator is used between two pointer variables, the expression is testing whether ________.
- Question 45 options:
- A) the value pointed to by the first is greater than the value pointed to by the second
- B) the first variable was declared before the second variable
- C) the address of the first variable comes before the address of the second variable in the computer's memory
- D) the value pointed to by the first is less than the value pointed to by the second
- E) None of these
- Question 46 (1 point)
- Question 46 Unsaved
- Use the delete operator only on pointers that were ________.
- Question 46 options:
- A) not correctly initialized
- B) dereferenced inappropriately
- C) never used
- D) created with the new operator
- E) None of these
- Save
- Question 47 (1 point)
- Question 47 Unsaved
- Which statement displays the address of the variable num1?
- Question 47 options:
- A) cin >> &num1;
- B) cout << &num1;
- C) cout << num1;
- D) cout << *num1;
- E) None of these
- Save
- Question 48 (1 point)
- Question 48 Unsaved
- Assuming ptr is a pointer variable, what will the following statement output?
- cout << *ptr;
- Question 48 options:
- A) The address of the variable stored in ptr.
- B) The string "*ptr".
- C) The value stored in the variable whose address is contained in ptr.
- D) The address of the variable whose address is stored in ptr.
- E) None of these
- Save
- Question 49 (1 point)
- Question 49 Unsaved
- If you are using an older compiler that does not support the C++ 11 standard, you should initialize pointers with ________.
- Question 49 options:
- A) the integer 0, or the value NULL
- B) a nonzero value
- C) the null terminator '\0'
- D) All of these
- E) None of these
- Save
- Question 50 (1 point)
- Question 50 Unsaved
- When you pass a pointer as an argument to a function, you must ________.
- Question 50 options:
- A) dereference the pointer variable in the function prototype
- B) declare the pointer variable again in the function call
- C) not dereference the pointer in the function's body
- D) use the #include statement
- E) None of these
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement