wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Arrays and Strings in C

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

A sequential collection of homogeneous elements is called_____

a)

variable

b)

constant

c)

Array

d)

keyword

2.

Fill in the blank

printf("Numbers from 1 to 10 in reverse order:")

for(i=10;i>0;___)

printf("%d\n",i);

a)

i++

b)

i=i+1

c)

i+=2

d)

i--

3.

special character which is stored at the end of string is ___

a)

\n

b)

\0

c)

\t

d)

\b

4.

____ is the control character used for strings

a)

%c

b)

%d

c)

%f

d)

%s

5.

____is the function used to compare two strings

a)

strcmp()

b)

strcpy()

c)

strlen()

d)

strcat()

6.

Number of bytes required to store a character is

a)

1 byte

b)

2 bytes

c)

4 bytes

d)

8 bytes

7.

_____is a sequential collection of heterogeneous elements

a)

Array

b)

structure

c)

string

d)

function

8.

Identify the error

int a[];

a[0]=35;

a[1]=46;

printf("%d\t%d",a[0],a[1]);

a)

size not specified in declaration of array

b)

printf statement is wrong

c)

assignment is wrong

d)

can not use index 0

9.

What is the output of following code snippet?

char msg[20]="welcome to c programming lab";

int len;

len=strlen(msg);

printf("length=%d",len);

a)

25

b)

28

c)

24

d)

29

10.

What is the output of strcmp() when strings are equal?

a)

1

b)

0

c)

negative value

d)

positive value