1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is an array in C++?
A data structure that stores multiple values of the same type, ordered and accessed by index.
How do you declare an array in C++?
An array declaration includes three parts: the type of data, the identifier (name), and the size (number of values the array will hold).
Why do arrays in C++ start indexing at zero?
Zero-based indexing allows the array identifier to refer to the starting memory address, where array[0] is the first value.
What happens if you access an index out of bounds in C++?
Accessing an invalid index (e.g., array[n] or array[-1]) can lead to undefined behavior and possible program crashes.
What is a parallel array?
A set of arrays that use the same index to associate related data, e.g., quiz scores for the same students.
What are two methods to access elements in a vector?
Elements can be accessed using square brackets (e.g., vector[i]) or the .at() method (e.g., vector.at(i)).
What does the method .push_back() do to a vector?
It increases the size of the vector by adding a new element to the end.
What is the difference between a classic for loop and a range-based for loop in C++?
A classic for loop uses an index to access elements, while a range-based for loop iterates directly over the values in the collection.
How do you initialize an array using an initialization list?
An initialization list is a brace-delimited, comma-separated list of values assigned starting from index zero.
What should you remember when processing arrays with loops?
Ensure your loop counters respect the valid index range, which is from 0 to (size - 1).