wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

OCS752_CP_WEEKLY_TEST3 (20.08.2020)

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

What is an Array in C language.?

a)

A group of element 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.

2.

what will be the output of the following in C?

#include<stdio.h>

int main()

{

int arr[1] = {10};

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

return 0;

}

a)

1

b)

0

c)

10

d)

-1

3.

What is the output of C Program.?

int main()

{

int a[];

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

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

}

a)

1

b)

2

c)

4

d)

Compiler error

4.

What is the output of C Program.?

int main()

{

int a[3] = {10,12,14};

a[1]=20;

int i=0;

while(i<3)

{

printf("%d ", a[i]); i++;

}

}

a)

20 12 14

b)

10 20 14

c)

10 12 20

d)

Compiler error

5.

What is an array Base Address in C language.?

a)

Base address is the address of 0th index element.

b)

An array b[] base address is &b[0]

c)

An array b[] base address can be printed with printf("%d", b);

d)

All the above

6.

An entire array is always passed by ___ to a called function.

a)

Call by value

b)

Call by reference

c)

Address relocation

d)

Address restructure

7.

How do you initialize an array in C?

a)

int arr[3] = (1,2,3);

b)

int arr(3) = {1,2,3};

c)

int arr[3] = {1,2,3};

d)

int arr(3) = (1,2,3);

8.

Elements in an array are accessed _____________

a)

randomly

b)

sequentially

c)

exponentially

d)

logarithmically

9.

What are the elements present in the array of the following C code?

int array[5] = {5};

a)

5, 5, 5, 5, 5

b)

5, 0, 0, 0, 0

c)

5, (garbage), (garbage), (garbage), (garbage)

d)

(garbage), (garbage), (garbage), (garbage), 5

10.

An array elements are stored in __________ memory locations.

a)

sequential

b)

random

c)

sequential and random

d)

None of the above

11.

what will be the output of the following c code?

void main()

{

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

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

}

a)

5

b)

6

c)

0

d)

Garbage value

12.

what will be the output of the following C code?

void main()

{

int a[10];

printf("%d%d",a[-1],a[12]);

}

a)

0 0

b)

Garbage value 0

c)

code will not compile

d)

garbage value garbage value

13.

what will be the output of this program?

void main()

{

float arr[] = { 10.2, 34.5, 65.4, 89.43 };

printf(%d", sizeof (arr) / sizeof (arr[0])) ;

}

a)

5

b)

4

c)

7

d)

0

14.

What is the maximun number of dimensions an array in C may have?

a)

Two

b)

eight

c)

sixteen

d)

Theoretically no limit. The only practical limits are memory size and compilers

15.

Let x be an array.Which of the following operations is illegal?

i) ++x.

ii) x+1.

iii) x++.

iv) x*2

a)

I and II

b)

I, II and III

c)

II and III

d)

III and IV

16.

What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and starting address of the array is 4000?

a)

4048

b)

4056

c)

4052

d)

4042

17.

Size of the array need not be specified, when

a)

Initialization is a part of definition

b)

It is a declaratrion

c)

It is a formal parameter

d)

All of these

18.

Consider the array definition


int num [10] = {3, 3, 3};


Pick the Correct answers

a)

num [9] is the last element of the array num

b)

The value of num [ 8] is 3

c)

The value of num [ 3 ] is 3

d)

None of the above

19.

Consider the statement


int val[2] [4] = { 1, 2, 3, 4, 5, 6, 7, 8} ;


4 will be the value of

a)

val[0 ][ 3]

b)

val[0][4]

c)

val[1][1]

d)

none of the above

20.

Which of the following is a two-dimensional array?

a)

array anarray[20][20];

b)

int anarray[20][20];

c)

int array[20, 20];

d)

char array[20];