wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Array and string unit 7

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the correct way to declare a string in C

a)

a. string name;

b)

b. char name[];

c)

c. char name();

d)

d. string[] name;

2.

Which library is used for string manipulation functions in C

a)

string.h

b)

stdio.h

c)

math.h

d)

time.h

3.

What function is used to find the length of a string in C

a)

len()

b)

length()

c)

strlen()

d)

strlength()

4.

Which function is used to concatenate two strings in C

a)

strcat()

b)

all

c)

concat()

d)

. append()

5.

What is the correct way to compare two strings in C

a)

strcompare()

b)

compare()

c)

strcmp()

d)

str_equal()

6.

Which function is used to copy one string to another in C

a)

copy()

b)

strcopy()

c)

strcpy()

d)

duplicate()

7.

Which character is used to represent the end of a string in C

a)

\n

b)

0

c)

\0

d)

1

8.

What is the primary difference between an array and a string in C

a)

Arrays are one-dimensional, and strings are two-dimensional.

b)

Arrays are fixed-size collections, while strings are dynamic.

c)

Arrays can store any data type, while strings specifically store characters.

d)

Arrays are null-terminated, and strings are not.

9.

How are arrays and strings related in C

a)

Arrays and strings are entirely different concepts.

b)

Arrays are a more flexible version of strings.

c)

Strings are a specific use case of character arrays.

d)

Arrays can only store integers, while strings can store characters.

10.

What is the purpose of the null character ('\0') in C strings

a)

It marks the end of the array.

b)

It signifies the end of the string.

c)

It represents a space character in strings.

d)

It indicates the beginning of the string.