Font size
WorksheetsHackharbor 3.0 Day 3:C
Total questions: 20
Worksheet time: 10mins
What does the * operator do when used with a pointer?
Declares a pointer
Returns the size of the memory block
Dereferences the pointer to access the value
Increments the pointer
What does the & operator do in C?
Multiplication
Access value at a memory address
Get memory address of a variable
Error
What must be done after dynamic memory is no longer needed?
Nothing
Use delete
Use realloc()
Use free()
What best describes the relationship between a pointer and the variable it points to?
A loyal friend who never leaves
An emotionally distant partner who only remembers the address
A clingy ex who still knows where you live
Just roommates
What is the correct way to declare a pointer to an integer?
int ptr;
int &ptr;
int *ptr;
pointer int ptr;
What exactly is a “pointer to a pointer”?
A friend who tells you where another friend is
A directory full of pizza recipes
A function that can’t make up its mind
A pointer that’s been left on read
What is the output of this code?
1
2
Garbage value
Address of p
What will the expression *(arr + i) return in an integer array?
The address of arr[i]
The value of arr[i]
The size of the array
An error
Why should you always free() memory after using malloc()?
Because memory deserves closure
Because your program is not your parent—it shouldn't clean up after you
Because malloc() feels suffocated otherwise
To impress the C compiler
In C, the name of an array acts as:
Value of the first element
Pointer to the last element
Pointer to the first element
Memory location of the entire array
What is the main difference between calloc() and malloc()?
malloc() is slower
calloc() allocates memory without initialization
calloc() initializes memory to 0
malloc() takes two arguments
Which header is needed for malloc() and calloc()?
math.h
string.h
stdlib.h
stdio.h
Why is calloc() considered the “nicer” cousin of malloc()?
Because it gives you memory and initializes it like a good parent
It brings snacks
It doesn’t ask many questions
Because it says “please” and “thank you”
When passing a pointer to a function to modify a value, what are you essentially doing?
Giving your friend a copy of your house keys
Calling tech support
Gossiping behind the variable’s back
Sending a postcard to memory
Which of the following will double the size of a previously allocated array? int *arr = malloc(4 * sizeof(int));
realloc(arr, 4);
realloc(arr, 2);
realloc(arr, 8 * sizeof(int));
realloc(arr, sizeof(int));
What does int **ptr; mean?
Pointer to int
Double pointer
Void pointer
Memory block
Which statement is true about function arguments passed using pointers?
Values are copied
Only local copy is modified
Original values can be modified
Pointer is always global
What happens if you try to access memory after it has been freed?
The program behaves normally
Memory is automatically reallocated
It causes undefined behavior
It throws an exception
You ran a program with infinite recursion. What’s the most likely ending?
It returns love
It becomes self-aware
Stack overflow
You get an internship
How confident do you feel about pointers in C?
I LOVE POINTERS
I HATE POINTERS
I WAS SLEEPING IN CLASS
WHAT ARE POINTERS?
