WorksheetsCHAPTER 7a
Total questions: 10
Worksheet time: 5mins
Q1. What does the statement int tests[5]; do?
A. Declares a pointer to 5 integers
B. Declares a variable named tests
C. Declares an array of 5 integers
D. Declares 5 separate variables
Q2. In C++, what is the subscript of the last element in an array of size 10?
A. 10
B. 9
C. 1
D. Undefined
Q3. What happens when you access an array index out of bounds in C++?
A. The compiler throws an error
B. It resets the program
C. It may corrupt memory or crash
D. It shows a warning
Q4. Which of the following is the correct way to initialize all elements of a local array numbers[5] to 99?
A. numbers = 99;
B. fill(numbers, 99);
C. for(int i=0;i<5;i++) numbers[i]=99;
D. numbers[5] = {99};
Q5. What is the result of this array initialization? int tests[5] = {1, 2};
A. Compiler error
B. Only first element initialized
C. First two elements initialized, others set to 0
D. All elements set to 1 and 2
Q6. Which of the following is true about character arrays?
A. They cannot be initialized with strings
B. They must always end with a number
C. You can output the array by passing its name to cout
D. They use more memory than integer arrays
Q7. Which of the following array definitions is invalid?
A. int scores[10];
B. double marks[4.5];
C. const int SIZE = 100; int arr[SIZE];
D. char name[] = "Test";
Q8. What is an off-by-one error in the context of arrays?
A. Incorrect loop syntax
B. Using the wrong variable
C. Accessing beyond array size by 1
D. Using incorrect data type
Q9. What is the size in bytes of the array int numbers[4]; if int takes 4 bytes?
A. 8
B. 16
C. 20
D. 12
Q10. Which concept refers to two arrays being related by their index values?
A. Shared memory arrays
B. Parallel arrays
C. Dynamic arrays
D. Multidimensional arrays
