wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DAY 4 - Arrays & String Assessment _14 June 24

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

How do you declare a one-dimensional array of integers with 10 elements in C?

a)

int array[10];

b)

int array(10);

c)

int array{10};

d)

int array;

2.

is the index of the last element in a one-dimensional array with 5 elements?

a)

4

b)

5

c)

0

d)

1

3.

How do you access the element at the second row and third column of a two-dimensional array arr?

a)

arr[2][3]

b)

arr[1][2]

c)

arr[3][2]

d)

arr[2, 3]

4.

What will be the output of the following C code snippet?

a)

1

b)

2

c)

3

d)

Compilation error

5.

What is the correct syntax to initialize a two-dimensional array in C?

a)

int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};

b)

int arr[2, 3] = {1, 2, 3, 4, 5, 6};

c)

int arr{2, 3} = {1, 2, 3, 4, 5, 6};

d)

int arr[2][3] = {1, 2, 3, 4, 5, 6};

6.

How do you declare a string in C?

a)

char str[10];

b)

string str;

c)

char str;

d)

str[10] = char;

7.

What is the correct way to initialize a string with the value "Hello"?

a)

char str[] = "Hello";

b)

char str[] = {'H', 'e', 'l', 'l', 'o'};

c)

char str[5] = "Hello";

d)

char str[5] = {'H', 'e', 'l', 'l', 'o'};

8.

Which library function is used to find the length of a string in C?

a)

strlen()

b)

strcpy()

c)

strcat()

d)

strcmp()

9.

What will be the output of the following C code snippet?

a)

ello

b)

Hello

c)

H

d)

Compilation error

10.

What is the output of the following C code snippet?

a)

W

b)

l

c)

o

d)

r