wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CPR_Quiz_Arrays and strings

Total questions: 20

Worksheet time: 28mins

Name
Class
Date
1.

What is right way to Initialize array?

a)

int num[6] = { 2, 4, 12, 5, 45, 5 };

b)

int n{} = { 2, 4, 12, 5, 45, 5 };

c)

int n{6} = { 2, 4, 12 };

d)

int n(6) = { 2, 4, 12, 5, 45, 5 };

2.

An array elements are always stored in ________ memory locations.

a)

sequential

b)

Random

c)

Sequential and Random

d)

None of the above

3.

what will be printed after Execution of the following program

void main()

{

int a[5]={11,13,56,20,5};

printf("%d",a[2]);

}

a)

garbage value

b)

13

c)

56

d)

20

4.

if two strings are identical then function strcmp() returns

a)

0

b)

-1

c)

true

d)

none of these

5.

what will be the output of the program?

#include <stdio.h>

#include<string .h>

void main()

{

char str1[20]="Hello",str2="world";

strcat(str1,str2);

puts(str1);

return 0;

}

a)

Hello

b)

world

c)

Helloworld

d)

none of the above

6.

8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

a)

arr[6]

b)

arr[7]

c)

arr{6}

d)

arr{7}

7.

string concatenation means?

a)

combining two strings.

b)

Extracting a sub string out of a string.

c)

Partitioning the string into two strings.

d)

Merging two strings.

8.

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

9.

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

10.

An array Index starts with.?

a)

-1

b)

0

c)

1

d)

2

11.

What is the output of C Program.?


int main()

{

int a[] = {1,2,3,4};

int b[4] = {5,6,7,8};

printf("%d,%d", a[0], b[0]);

}

a)

1,5

b)

2,6

c)

0 0

d)

Compiler error

12.

What is the output of C program with arrays.?


int main()

{

int a[3] = {20,30,40};

int b[3];

b=a;

printf("%d", b[0]);

}

a)

20

b)

30

c)

address of 0th element.

d)

Compiler error

13.

What is an Array in C language.?

a)

A group of elements of same data type.

b)

An array contains more than one element

c)

Array elements are stored in memory in continuous or contiguous locations.

d)

All the above.

14.

What is the output of C Program with arrays.?


int main()

{

int rollno[3]=[1001,1002,1003];

printf("%d", rollno[1]);

}

a)

1002

b)

1003

c)

address of 1002

d)

Compiler error

15.

What is the minimum and maximum Indexes of this below array.?

int main()

{

int ary[9];

return 0;

}

a)

-1, 8

b)

0, 8

c)

1,9

d)

None of the above

16.

What is the dimension of the below C Array.?

int ary[]={1,3,5,7};

a)

1

b)

2

c)

3

d)

5

17.

What is the dimension of the C array int ary[10][5].?

a)

1

b)

2

c)

5

d)

10

18.

Which of the following function is more appropriate for reading in a multi-word string?

a)

scanf()

b)

printf()

c)

puts()

d)

gets()

19.

What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?

a)

%c

b)

%C

c)

%s

d)

%w

20.

What is meaning of following declaration ?

int arr[20];

a)

None of these

b)

Array of Size 20

c)

Integer Array of size 20

d)

Array of size 20 that can have integer address