Recall & Review
beginner
What is a pointer in C++?
A pointer is a variable that stores the memory address of another variable. It 'points' to the location where data is stored.
Click to reveal answer
beginner
How are arrays and pointers related in C++?
The name of an array acts like a pointer to its first element. You can use pointers to access array elements by moving through memory addresses.
Click to reveal answer
intermediate
What does the expression *(arr + i) mean?
It means accessing the element at index i of the array arr by moving i positions from the start address and dereferencing the pointer.
Click to reveal answer
beginner
How do you declare a pointer to an integer in C++?
You declare it like this:
int* ptr; where ptr can store the address of an integer variable.Click to reveal answer
intermediate
What happens if you increment a pointer pointing to an array element?
Incrementing the pointer moves it to the next element in the array, because it increases the address by the size of the element type.
Click to reveal answer
What does the pointer variable store?
✗ Incorrect
Pointers store the memory address where data is located, not the data itself.
If
int arr[5];, what does arr represent?✗ Incorrect
The array name acts as a pointer to its first element.
What does
*(arr + 2) access?✗ Incorrect
Pointer arithmetic moves by element size, so adding 2 moves to the third element (index 2).
How do you declare a pointer to a float variable?
✗ Incorrect
The correct syntax is
float* ptr;.What happens when you do
ptr++ if ptr points to an int array element?✗ Incorrect
Incrementing a pointer moves it by the size of the type it points to, so to the next int element.
Explain how pointers and arrays are connected in C++.
Think about how the array name can be used like a pointer to the first element.
You got /3 concepts.
Describe what happens when you increment a pointer that points to an array element.
Consider how memory addresses change when moving through an array.
You got /3 concepts.