wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Array and String

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Defining arrays:

a)

int c[ ];

b)

int c;

c)

int c[20];

2.

Identify the error



(a)  

3.

Given :

int array[5]={1,4,8,5,6};


What is the output for:

array[2]

a)

1

b)

4

c)

8

d)

5

4.

Given :

int array[5]={1,4,8,5,6};


What is the output for:

array[2+1]

a)

1

b)

4

c)

8

d)

5

5.

Given :

int array[5]={1,4,8,5,6};


What is the output for:

array[2]+2

a)

6

b)

10

c)

7

d)

6

6.

An array can store many different types of value.

a)

True

b)

False

7.

Find the error:


#define SIZE 10;

(a)  

8.

Write a single statement to accomplish the following:


Copy the string stored in array s2 into array s1.

a)

strcpy(s1,s2);

b)

strncpy(s1,s2);

c)

strcpy(s2,s1);

d)

strncpy(s2,s1);

9.

Functions that can be used to read the characters entered by user.

a)

printf()

b)

scanf()

c)

getchar()

d)

puts()

10.

assume:

s1[20]="Happy ";

s2[20]="New Year";


which string-manipulation functions can be used to appends string s2 to s1?

a)

strncat(s1,s2);

b)

strcat(s1,s2);

c)

strcpy(s1.s2);

d)

strncpy(s1,s2);