📦 Section 2 · Arrays & Pointers
🟣 Checkpoint Quiz
MODULE 10 · QUIZ
Pointers & Arrays Quiz
Your progress in Section 2100%
🎯 What this checkpoint covers: This is a review lesson, not new teaching. It's a 12-question assessment pulling from everything in Section 2 — Lessons 6 through 9: arrays (1D and 2D), strings, pointers, and dynamic memory. Skim the recap below, then take the quiz.
Recap
Section 2 in a Nutshell
Before the quiz, here's a compressed recap of the four lessons you've completed. If any of these points feel unfamiliar, it's worth a quick re-read of that lesson before you continue.
1
Lesson 6 — Arrays: 1D and 2D
An array is a fixed-size collection of same-type values, indexed from
0. int arr[10]; has valid indices 0 through 9 — the compiler does not check bounds for you. A 2D array like int grid[3][4]; is accessed with two bracket pairs: grid[row][col].2
Lesson 7 — Strings
std::string is the modern, safe way to work with text — it manages its own memory and resizes automatically, unlike raw C-style char arrays. Useful members include .length()/.size(), + for concatenation, .substr(), .find(), and direct comparison with ==.3
Lesson 8 — Pointers
& is the address-of operator — &x gives you the memory address where x lives. * is the dereference operator — given int* p = &x;, writing *p reads or writes the value stored at that address. Array names decay into a pointer to their first element in most expressions.4
Lesson 9 — Dynamic Memory
new allocates a single value on the heap, freed with delete. new[] allocates a heap array, freed with the matching delete[]. Forgetting to free heap memory causes a memory leak; using a pointer after it's been deleted leaves a dangling pointer — always set it to nullptr right after deleting.✨
The thread connecting all four lessons
Arrays, strings, pointers, and dynamic memory are really one continuous idea: a block of values sitting somewhere in memory, and a way to reach it. An array name, a
std::string's internal buffer, and a raw pointer returned by new[] are all, underneath, addresses pointing at the start of a run of memory — just with very different amounts of safety wrapped around them.Quick Reference
One Program, All Four Topics
Here's a single short program that touches every topic in this checkpoint — a 1D array, a std::string, a pointer using &/*, and a correctly-freed heap allocation.
quick_reference.cpp
C++
// quick_reference.cpp #include <iostream> #include <string> using namespace std; int main() { // 1D array int scores[5] = {88, 92, 75, 100, 64}; // std::string string label = "Scores"; // pointer: & to get an address, * to dereference it int* firstScore = &scores[0]; cout << label << " — first entry via pointer: " << *firstScore << endl; // dynamic memory: allocate, use, free int* heapCopy = new int[5]; for (int i = 0; i < 5; i++) { heapCopy[i] = scores[i]; } cout << "Heap copy: "; for (int i = 0; i < 5; i++) { cout << heapCopy[i] << " "; } cout << endl; delete[] heapCopy; // matches new[] with delete[] heapCopy = nullptr; // avoid a dangling pointer return 0; }
⚠️
Common trap this section loves to test
Mixing up
delete with delete[], forgetting a delete entirely (a leak), or reading through a pointer after it's been freed (a dangling pointer) are the three mistakes that show up most in real C++ code — and in this quiz.🧩 Pointers & Arrays Checkpoint — 12 Questions
Answer all 12 questions to test your mastery of Section 2. Instant feedback on every answer.
1. What is the valid index range for
int arr[10];?2. In a 2D array declared
int grid[3][4];, how do you access the element in row 1, column 2?3. What happens when you access an index outside an array's bounds, like
arr[15] on a 10-element array?4. Which type is the modern, safer choice for working with text in C++, compared to raw C-style
char arrays?5. Given
std::string s = "Hello";, what does s.length() return?6. What does the
& operator do when placed directly before a variable name, like &age?7. Given
int x = 10; int* p = &x;, what does *p do?8. What does an array's name "decay" into when passed to a function?
9. Which expression correctly allocates a single
int on the heap?10. Which operator must you use to free memory allocated with
new int[50];?11. What is a memory leak?
12. After
delete ptr;, why is it good practice to immediately write ptr = nullptr;?Finished the checkpoint?
Mark it complete to track your progress.
Module 10 of 26
Section 2 — Arrays, Strings & Pointers