Recall & Review
beginner
What is the syntax to declare an array of 5 integers in C++?
You declare it like this:
int arr[5]; This creates an array named arr that can hold 5 integers.Click to reveal answer
beginner
How do you access the third element of an array named
arr?You use the index 2 because counting starts at 0. So,
arr[2] gives you the third element.Click to reveal answer
intermediate
How can you find the size of a statically declared array
arr in C++?Use
sizeof(arr) / sizeof(arr[0]). This divides the total bytes of the array by the bytes of one element to get the number of elements.Click to reveal answer
intermediate
What is the difference between
arr[i] and *(arr + i)?Both access the element at index
i. arr[i] is array indexing syntax, while *(arr + i) uses pointer arithmetic. They are equivalent.Click to reveal answer
intermediate
How do you copy elements from one array to another in C++?
You can use a loop to copy each element one by one, like:<br>
for(int i = 0; i < size; i++) { dest[i] = src[i]; }<br>Or use std::copy from the <algorithm> header.Click to reveal answer
What is the index of the first element in a C++ array?
✗ Incorrect
In C++, array indexing starts at 0, so the first element is at index 0.
Which expression correctly gives the number of elements in a statically declared array
arr?✗ Incorrect
Dividing the total size of the array by the size of one element gives the number of elements.
What does
arr[3] mean in C++?✗ Incorrect
Indexing starts at 0, so
arr[3] is the fourth element.Which of the following copies elements from one array to another correctly?
✗ Incorrect
Arrays cannot be assigned directly; you must copy elements one by one or use std::copy.
What is the result of
*(arr + 2)?✗ Incorrect
Pointer arithmetic moves the pointer by 2 elements, so dereferencing gives the third element.
Explain how to declare, access, and find the size of a static array in C++.
Think about how memory size relates to element count.
You got /3 concepts.
Describe two ways to copy elements from one array to another in C++.
Remember arrays cannot be assigned directly.
You got /2 concepts.