wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Pointer

Total questions: 8

Worksheet time: 4mins

Name
Class
Date
1.

Local variables are stored in an area called____________

a)

Heap

b)

Permanent storage area

c)

Stack

d)

Free memory

2.

The size of both stack and heap remains the same during run time.

a)

True

b)

False

3.

Which of the following is an example for non linear data type?

a)

Array

b)

Tree

c)

Linked List

d)

Stack

4.

The advantage of using linked lists over arrays is that________________________

a)

Linked list is an example of linear data structure

b)

Insertion and deletion of an element can be done faster in a linked list

c)

Linked list can be used to store a collection of homogeneous and heterogeneous data types

d)

The size of a linked list is fixed

5.

What is the return type of malloc() or calloc()?

a)

Pointer of allocated memory type

b)

void**

c)

void*

d)

int*

6.

What is the problem with following code?

#include<stdio.h>

int main(){

int *p = (int *)malloc(sizeof(int));

p = NULL;

free(p);

}

a)

Dangling pointer

b)

The program may crash as free() is called for NULL pointer

c)

Memory Leak

d)

Compiler Error: free can't be applied on NULL pointer

7.

What is the problem with following code?

#include<stdio.h>

int main(){

int *p = (int *)malloc(sizeof(int));

free(p);

}

a)

Dangling pointer

b)

The program may crash as free() is called for NULL pointer

c)

Memory Leak

d)

Compiler Error: free can't be applied on NULL pointer

8.

Which languages necessarily need heap allocation in the run time environment?

a)

Those that support recursion

b)

Those that allow dynamic data structures

c)

Those that use dynamic scoping

d)

Those that use dynamic scoping