wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Array Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the index of the first element in an array in C?

a)

0

b)

1

c)

-1

d)

Depends on the array size

2.

What will be the output of the following code? int arr[5] = {1, 2, 3, 4, 5}; printf("%d", arr[2]);

a)

1

b)

2

c)

3

d)

4

3.

Which of the following correctly declares an array in C?

a)

int array;

b)

array int[5];

c)

int array[5];

d)

int[5] array;

4.

What is the output of the following code? int arr[3] = {10, 20, 30}; printf("%d", arr[5]);

a)

10

b)

30

c)

Garbage value

d)

Error

5.

What is the size (in bytes) of the array int arr[10]; assuming int is 4 bytes?

a)

10

b)

40

c)

4

d)

14

6.

Which of the following is used to access elements of an array in C?

a)

( )

b)

{ }

c)

[ ]

d)
7.

What happens if you try to store more elements than declared in an array?

a)

Compiler will expand the array

b)

Runtime error

c)

Compile-time error

d)

Undefined behavior

8.

Which of the following statements is true about arrays in C?

a)

The size of an array can be changed at runtime

b)

Array elements are stored in stack memory only

c)

Array index can be negative

d)

Array elements are stored in contiguous memory locations

9.

How do you find the number of elements in an array int arr[10]; in C?

a)

sizeof(arr)

b)

sizeof(arr)/sizeof(int)

c)

length(arr)

d)

count(arr)

10.

What is the correct way to initialize all elements of an array to 0?

a)

int arr[10] = {0};

b)

int arr[10] = (0);

c)

int arr[10] = 0;

d)

int arr[10]; arr = 0;