Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CHAPTER 7a

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Q1. What does the statement int tests[5]; do?

a)

A. Declares a pointer to 5 integers

b)

B. Declares a variable named tests

c)

C. Declares an array of 5 integers

d)

D. Declares 5 separate variables

2.

Q2. In C++, what is the subscript of the last element in an array of size 10?

a)

A. 10

b)

B. 9

c)

C. 1

d)

D. Undefined

3.

Q3. What happens when you access an array index out of bounds in C++?

a)

A. The compiler throws an error

b)

B. It resets the program

c)

C. It may corrupt memory or crash

d)

D. It shows a warning

4.

Q4. Which of the following is the correct way to initialize all elements of a local array numbers[5] to 99?

a)

A. numbers = 99;

b)

B. fill(numbers, 99);

c)

C. for(int i=0;i<5;i++) numbers[i]=99;

d)

D. numbers[5] = {99};

5.

Q5. What is the result of this array initialization? int tests[5] = {1, 2};

a)

A. Compiler error

b)

B. Only first element initialized

c)

C. First two elements initialized, others set to 0

d)

D. All elements set to 1 and 2

6.

Q6. Which of the following is true about character arrays?

a)

A. They cannot be initialized with strings

b)

B. They must always end with a number

c)

C. You can output the array by passing its name to cout

d)

D. They use more memory than integer arrays

7.

Q7. Which of the following array definitions is invalid?

a)

A. int scores[10];

b)

B. double marks[4.5];

c)

C. const int SIZE = 100; int arr[SIZE];

d)

D. char name[] = "Test";

8.

Q8. What is an off-by-one error in the context of arrays?

a)

A. Incorrect loop syntax

b)

B. Using the wrong variable

c)

C. Accessing beyond array size by 1

d)

D. Using incorrect data type

9.

Q9. What is the size in bytes of the array int numbers[4]; if int takes 4 bytes?

a)

A. 8

b)

B. 16

c)

C. 20

d)

D. 12

10.

Q10. Which concept refers to two arrays being related by their index values?

a)

A. Shared memory arrays

b)

B. Parallel arrays

c)

C. Dynamic arrays

d)

D. Multidimensional arrays