wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C-Lab10

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which library is needed for Dynamic memory allocation?

a)

malloc.h

b)

memory.h

c)

stdlib.h

d)

calloc.h

2.

The default address stored in a pointer is :

a)

Hexadecimal

b)

integer

c)

long long integer

d)

double

3.

If ptr is a pointer variable pointing to an array, then

"printf("%d",*(ptr++)) ;"

statement will print :

a)

Next location address

b)

Next location index value

c)

Next location value

d)

Compile time error

4.

malloc() stands for :

a)

malicious location

b)

memory allocation

c)

multiple allocation

d)

multi-alternate locations

5.

calloc() function takes :

a)

One parameter

b)

Two parameters

c)

Two parameters but one is optional

d)

Zero parameters

6.

Dynamically allocated memory is released by :

a)

release()

b)

dealloc()

c)

free()

d)

Compiler automatically

7.

Passing address to a function as parameters is called

a)

Default function call

b)

Call by value

c)

Call by reference

d)

Call by pointers

8.

The code to swap the values of two variables using pointers is given : TRUE / FALSE ?


temp = &ptr1 ;

&ptr1 = &ptr2 ;

&ptr2 = temp ;

a)

TRUE

b)

FALSE

9.

From the given code, find the output :

char a[3] = {'a', '5' , '$'};

ptr=a;

for(i=1;i<=3;i++)

printf("%ld", a++);

a)

a 5 $

b)

124563 124564 124565

c)

124563 124567 124571

d)

Junk : 125845658 -25648569 -2564875

10.

Given the code, what will be the output:

a=5; b=2;c=0;

ptr1 = &a; ptr2 = &b; ptr3 = &c;

ptr3 = *ptr1 * *ptr2;

printf(%d", *ptr3);

a)

Compiler Error : Usage of double pointer without declaring

b)

Compiler Error : Addresses cannot be multiplied

c)

10

d)

Compiler Error : Operator * followed by value