Folder101   Home Notes Quiz Assigns Info  
Forum Forum
101 Home 101
 
  C++ Level 2

Practice Quiz 4 - Arrays, Characters and Strings


There are 10 questions in this quiz

Question 1: Multiple Choice       

Which of the following statements is FALSE?

Choice 1 an array is a series of storage locations
Choice 2 you can create an array of different data types
Choice 3 an array is made up of elements
Choice 4 each element in an array has an index number

Question 2: Multiple Choice       

C++ arrays start with the 0th element.

Choice 1 true
Choice 2 false
Choice 3 you can specify the element numbers
Choice 4 only if they are integer arrays

Question 3: Multiple Choice       

Which of the following statements is FALSE?

Choice 1 accessing elements in an array is done by using index numbers
Choice 2 array elements are stored contiguously in memory
Choice 3 strings are arrays of characters with a (\0) at the end
Choice 4 strings are arrays of characters with a (\n) at the end

Question 4: Multiple Choice      

Which of the following correctly declares an array?

Choice 1 int myArray[10];
Choice 2 int myArray 10;
Choice 3
array myArray[10];
Choice 4 int[10] myArray;

Question 5: Multiple Choice       

What is the index number of the last element of an array with 100 elements?

Choice 1 101
Choice 2 100
Choice 3 99
Choice 4 98

Question 6: Multiple Choice     

Which of the following correctly accesses the 59th element stored in foo, an array with 100 elements?

Choice 1 foo[59];
Choice 2 foo(58);
Choice 3 foo(59);
Choice 4 foo[58];

Question 7: Multiple Choice       

To get the number of bytes in an array, you may use the:-

Choice 1 size() operator;
Choice 2 sizeof() operator
Choice 3 bytes() operator;
Choice 4 lengthof() operator;

Question 8: Multiple Choice       

All elements of an array are initialized to 0

Choice 1 only if it is an array of integers
Choice 2 true
Choice 3 false
Choice 4 false, elements in an array are initialized to 1

Question 9: Multiple Choice       

On which line is there an error in the following code?

   1. char numbers[5] = {'1', '2', '3', '4', '5'};
   2. cout
<< "April is month number " << numbers[3];
   3. cout <<
"May is month number " << numbers[4];
   4. cout <<
"June is month number " << numbers[5];

Choice 1 1
Choice 2 2
Choice 3 3
Choice 4 4

Question 10: Multiple Choice       

On which line is there an error in the following code?

   1. char ch[5];
   2. ch = "Hello"
   3. cout <<
ch[0] << endl;
   4. cout <<
ch[4] << endl;

Choice 1 1
Choice 2 2
Choice 3 3
Choice 4 4