08.ArraysAndVectors

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

What is an array in C++?

A data structure that stores multiple values of the same type, ordered and accessed by index.

2
New cards

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).

3
New cards

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.

4
New cards

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.

5
New cards

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.

6
New cards

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)).

7
New cards

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.

8
New cards

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.

9
New cards

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.

10
New cards

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).