wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

c-languiz

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array.

2.

What is the maximum length of a C String.?

a)

32 characters

b)

64 characters

c)

256 characters

d)

none of the above

3.

Choose a correct C Statement about Strings.

a)

PRINTF is capable of printing a multi word string.

b)

PUTS is capable of printing a multi word string.

c)

GETS is capable of accepting a multi word string from console or command prompt

d)

All the above

4.

If the two strings are identical, then strcmp() function returns

a)

-1

b)

1

c)

0

d)

yes

5.

What is the output of c program with strings?

int main()

{

char str[]={'g','l','o','b','e','\0'};

printf("%s",str);

return 0;

}

a)

g

b)

globe

c)

globe/0

d)

compiler error

6.

What is the output of c program with strings ?

int main()

{

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

printf("%s",str);

return 0;

}

a)

g

b)

globe

c)

globe/0

d)

none of the above!

7.

What is the output of c program with strings?

int main()

{

char str1[]="JOHN";

char str2[20];

str2= str1;

printf("%s",str2);

return 0;

}

a)

JOHN

b)

J

c)

JOHN/0

d)

Compiler error

8.

What is the output of c program with strings?

int main()

{

char str[2];

scanf("%s", str);

printf("%s",str);

return 0;

}

//Input: South

a)

Sou

b)

South

c)

Compiler error

d)

none of the above

9.

What is the output of c program with string arrays?

int main()

{

char *p1 = "GOAT";

char * p2;

p2 = p1;

p2="ANT";

printf("%s", p1);

}

a)

ANT

b)

GOAT

c)

G

d)

A

10.

What is the output of c program ?

int main()

{

int str[]={'g','l','o','b','e'};

printf("A%c ",str);

printf("A%s ",str);

printf("A%c ",str[0]);

return 0;

}

a)

A A A

b)

A Ag Ag

c)

A*randomchar* Ag Ag

(*same line)

d)

Compiler error