wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Hackharbor 3.0 Day 3:C

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What does the * operator do when used with a pointer?

a)

Declares a pointer

b)

Returns the size of the memory block

c)

Dereferences the pointer to access the value

d)

Increments the pointer

2.

What does the & operator do in C?

a)

Multiplication

b)

Access value at a memory address

c)

Get memory address of a variable

d)

Error

3.

What must be done after dynamic memory is no longer needed?

a)

Nothing

b)

Use delete

c)

Use realloc()

d)

Use free()

4.

What best describes the relationship between a pointer and the variable it points to?

a)

A loyal friend who never leaves

b)

An emotionally distant partner who only remembers the address

c)

A clingy ex who still knows where you live

d)

Just roommates

5.

What is the correct way to declare a pointer to an integer?

a)

int ptr;

b)

int &ptr;

c)

int *ptr;

d)

pointer int ptr;

6.

What exactly is a “pointer to a pointer”?

a)

A friend who tells you where another friend is

b)

A directory full of pizza recipes

c)

A function that can’t make up its mind

d)

A pointer that’s been left on read

7.

What is the output of this code?

a)

1

b)

2

c)

Garbage value

d)

Address of p

8.

What will the expression *(arr + i) return in an integer array?

a)

The address of arr[i]

b)

The value of arr[i]

c)

The size of the array

d)

An error

9.

Why should you always free() memory after using malloc()?

a)

Because memory deserves closure

b)

Because your program is not your parent—it shouldn't clean up after you

c)

Because malloc() feels suffocated otherwise

d)

To impress the C compiler

10.

In C, the name of an array acts as:

a)

Value of the first element

b)

Pointer to the last element

c)

Pointer to the first element

d)

Memory location of the entire array

11.

What is the main difference between calloc() and malloc()?

a)

malloc() is slower

b)

calloc() allocates memory without initialization

c)

calloc() initializes memory to 0

d)

malloc() takes two arguments

12.

Which header is needed for malloc() and calloc()?

a)

math.h

b)

string.h

c)

stdlib.h

d)

stdio.h

13.

Why is calloc() considered the “nicer” cousin of malloc()?

a)

Because it gives you memory and initializes it like a good parent

b)

It brings snacks

c)

It doesn’t ask many questions

d)

Because it says “please” and “thank you”

14.

When passing a pointer to a function to modify a value, what are you essentially doing?

a)

Giving your friend a copy of your house keys

b)

Calling tech support

c)

Gossiping behind the variable’s back

d)

Sending a postcard to memory

15.

Which of the following will double the size of a previously allocated array? int *arr = malloc(4 * sizeof(int));

a)

realloc(arr, 4);

b)

realloc(arr, 2);

c)

realloc(arr, 8 * sizeof(int));

d)

realloc(arr, sizeof(int));

16.

What does int **ptr; mean?

a)

Pointer to int

b)

Double pointer

c)

Void pointer

d)

Memory block

17.

Which statement is true about function arguments passed using pointers?

a)

Values are copied

b)

Only local copy is modified

c)

Original values can be modified

d)

Pointer is always global

18.

What happens if you try to access memory after it has been freed?

a)

The program behaves normally

b)

Memory is automatically reallocated

c)

It causes undefined behavior

d)

It throws an exception

19.

You ran a program with infinite recursion. What’s the most likely ending?

a)

It returns love

b)

It becomes self-aware

c)

Stack overflow

d)

You get an internship

20.

How confident do you feel about pointers in C?

a)

I LOVE POINTERS

b)

I HATE POINTERS

c)

I WAS SLEEPING IN CLASS

d)

WHAT ARE POINTERS?