C / C++ Quiz
Test your systems programming knowledge. — 8 questions
About the C / C++ Quiz
Test your systems programming knowledge. This quiz has 8 multiple-choice questions. Each question has one correct answer, and you see an explanation straight after you answer, so you learn from every question — including the ones you get wrong. There is no time limit and nothing to sign up for; your answers are not stored.
The questions follow the material in the C / C++ Essentials guide and the C / C++ cheatsheet. Read them first if you want to prepare, or take the quiz cold to find the gaps in what you know.
Questions in this quiz
Preview the questions below. Each answer and its explanation are hidden until you choose to reveal them, so you can still take the quiz above without spoilers.
1. What does a pointer store?
Show answer
Answer: B. The memory address of a variable
A pointer holds the memory address of another variable. Use & to take an address and * to dereference.
2. Which operator dereferences a pointer?
Show answer
Answer: B. *
* dereferences: *ptr gives the value at the stored address. & takes the address of a variable. -> dereferences and accesses a member.
3. What does malloc return if allocation fails?
Show answer
Answer: C. NULL
malloc returns NULL on failure. C does not use exceptions — always check the return value before using the pointer.
4. What is a C++ reference?
Show answer
Answer: B. An alias for an existing variable
A reference is an alias: int& ref = x means ref and x share the same memory. References cannot be null or re-seated.
5. Which header is required for cout in C++?
Show answer
Answer: B. <iostream>
<iostream> provides std::cout and std::cin. <stdio.h> provides the C-style printf/scanf.
6. What does delete[] do?
Show answer
Answer: B. Frees memory allocated with new[]
delete[] must match new[]. Using plain delete on an array is undefined behavior.
7. What is the difference between pass-by-pointer and pass-by-reference in C++?
Show answer
Answer: B. References cannot be null and need no dereference syntax
References are safer: they cannot be null, cannot be re-seated, and are accessed without * dereference syntax.
8. What is sizeof(int) on most modern systems?
Show answer
Answer: B. 4 bytes
int is 4 bytes on both 32-bit and 64-bit systems (per common ABIs). Use int64_t / long long for guaranteed 64-bit.
How to use this quiz
- Answer every question before reading the explanations below — retrieving an answer from memory is what makes it stick.
- Note the questions you missed and revisit the matching section of the guide or cheatsheet.
- Retake the quiz a day or two later. Spaced repetition is one of the most reliable ways to remember technical details.