Programming Quiz 4

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:10 PM on 4/1/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

30 Terms

1
New cards

Array Definition

A data structure containing a number of data values, all of which have the same type.

2
New cards

Two Core Requirements of Arrays

1) All elements must be the same data type. 2) Each element must have a unique index.

3
New cards

Array Declaration Syntax

Data-type [size];

4
New cards

Size Declarator

The integer constant expression inside the [ ] that indicates the number of elements in an array.

5
New cards

Array Memory Allocation

Values are stored in adjacent (contiguous) memory locations.

6
New cards

First Element Index

The index of the first element in any C++ array is always 0.

7
New cards

Last Element Index

The index of the last element in an array of size 'n' is n - 1.

8
New cards

Array Bounds Checking

C++ does not perform array bounds checking; using an invalid index leads to runtime errors or memory corruption.

9
New cards

Array Initialization List

Initializing an array at declaration using a comma-separated list inside braces { }.

10
New cards

Partial Initialization

If an array is partially initialized, the remaining uninitialized elements are set to zero.

11
New cards

Implicit Array Sizing

Determining the size of an array automatically by the number of items in the initialization list.

12
New cards

Array Assignment Rule

You cannot assign one array to another using the = operator; you must copy element-by-element.

13
New cards

Displaying Array Contents

Except for char arrays, you must use a loop to display each element of an array.

14
New cards

Range-Based for Loop (C++ 11)

A loop that iterates once for each element in an array: for (dataType rangeVar : arrayName).

15
New cards

Range-Based Loop with Reference (&)

Required if you want to modify the actual values inside the array while using a range-based loop.

16
New cards

Parallel Arrays

Two or more arrays that contain related data, where elements at the same subscript are related.

17
New cards

2D Array Declaration

Data_Type arrayName[rows][cols];

18
New cards

2D Array Memory Layout

Conceptually a grid, but stored in memory as a single continuous block of rows.

19
New cards

2D Array Initialization

Initialized row by row; nested braces are recommended for clarity.

20
New cards

Multi-dimensional Arrays

C++ allows arrays with any number of dimensions, such as 3D (rows, columns, and depth).

21
New cards

STL Vector

A dynamic data structure that can grow or shrink in size during execution.

22
New cards

Vector Header File

The preprocessor directive #include is required to use vectors.

23
New cards

push_back(value)

A vector member function that adds an element to the end of the vector.

24
New cards

pop_back()

A vector member function that removes the last element from a vector.

25
New cards

size() Member Function

Returns the number of elements currently stored in the vector.

26
New cards

at(index) Member Function

Returns the value of the element at a specific position, with built-in bounds checking.

27
New cards

capacity() Member Function

Returns the maximum number of elements a vector can store without allocating more memory.

28
New cards

clear() Member Function

Removes all elements from a vector, making it empty.

29
New cards

empty() Member Function

A boolean function that returns true if the vector contains no elements.

30
New cards

Subscript Operator [] with Vectors

Vectors can use [] just like arrays, but it does not provide bounds checking like at() does.

Explore top flashcards

flashcards
Semester 1 midterms science
21
Updated 108d ago
0.0(0)
flashcards
Prep Game Notes
31
Updated 435d ago
0.0(0)
flashcards
Gr 11 Bio - Evolution
54
Updated 1081d ago
0.0(0)
flashcards
SIS 342 FINAL EXAM
72
Updated 344d ago
0.0(0)
flashcards
Bio - Exam intra 1
108
Updated 550d ago
0.0(0)
flashcards
Welding Test. Airframe
35
Updated 479d ago
0.0(0)
flashcards
Semester 1 midterms science
21
Updated 108d ago
0.0(0)
flashcards
Prep Game Notes
31
Updated 435d ago
0.0(0)
flashcards
Gr 11 Bio - Evolution
54
Updated 1081d ago
0.0(0)
flashcards
SIS 342 FINAL EXAM
72
Updated 344d ago
0.0(0)
flashcards
Bio - Exam intra 1
108
Updated 550d ago
0.0(0)
flashcards
Welding Test. Airframe
35
Updated 479d ago
0.0(0)