Additional c++ flashcards

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/51

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.

52 Terms

1
New cards

What is the basic concept of arrays/vectors?

They store multiple elements of the same type in a single structure using indexed positions.

2
New cards

What is a vector in C++?

A dynamic array that can grow or shrink at runtime, defined in .

3
New cards

How do you declare a vector of ints named nums?

std::vector nums;

4
New cards

How do you add an element to the end of a vector?

Use nums.push_back(value);

5
New cards

What does vector.size() return?

The number of elements currently in the vector.

6
New cards

How do you access the 3rd element of vector v?

v[2] (indexing starts at 0).

7
New cards

What is vector.at(i) used for?

Safe element access with bounds checking.

8
New cards

What is the purpose of an iteration drill?

Practice looping through arrays/vectors using indices or range-based loops.

9
New cards

How do you iterate through a vector using a for loop?

for (int i=0; i<v.size(); i++) { … }

10
New cards

How do you iterate through a vector using a range-based loop?

for (int x : v) { … }

11
New cards

What are multiple vectors?

Using more than one vector in parallel to store related data.

12
New cards

How do you resize a vector to size 10?

v.resize(10);

13
New cards

What happens when a vector is resized larger?

New elements are default-initialized.

14
New cards

What is vector.back()?

Returns the last element of the vector.

15
New cards

What does pop_back() do?

Removes the last element of a vector.

16
New cards

How can loops modify vectors?

By accessing elements via index and reassigning them.

17
New cards

How can loops copy vectors?

Push each element from one vector into another.

18
New cards

How can loops compare vectors?

Check each element pair to see if they differ.

19
New cards

What is the general technique for swapping two variables?

Use a temporary variable: temp=a; a=b; b=temp;

20
New cards

What common bug occurs when reversing a vector?

Incorrect index boundaries when swapping front/back.

21
New cards

What is the main difference between arrays and vectors?

Arrays have fixed size; vectors are dynamic.

22
New cards

What is a 2D array?

An array with rows and columns, like int a[3][4].

23
New cards

How do you access element (2,3) in a 2D vector?

v[2][3]

24
New cards

What are C strings?

Null-terminated character arrays of type char[].

25
New cards

How do you declare a C string of size 20?

char name[20];

26
New cards

What does strlen() do?

Returns the length of a C string (before '\0').

27
New cards

What does strcpy() do?

Copies one C string into another.

28
New cards

What library is required for C string functions?

29
New cards

What does the cctype library contain?

Character classification functions like isalpha, isdigit.

30
New cards

What does isalpha(c) do?

Returns true if c is an alphabetic letter.

31
New cards

LAB: Output numbers in reverse – key skill?

Loop backward through a vector or array.

32
New cards

LAB: Middle item – key idea?

Indexing the middle: v[v.size()/2]

33
New cards

LAB: Output values below amount – concept?

Conditional filtering while looping.

34
New cards

LAB: Normalize list – concept?

Scale values so they sum to 1 or fit a range.

35
New cards

LAB: Word frequencies – technique?

Loop through words and count occurrences.

36
New cards

LAB: Contains the character – approach?

Loop through string and check each char.

37
New cards

What is a user-defined function?

A reusable block of code declared with a return type, name, and parameters.

38
New cards

What is a void function?

A function that does not return a value.

39
New cards

Why define functions in C++?

To reduce repetition and improve readability.

40
New cards

What is a mathematical function in C++?

A function that performs and returns a calculation.

41
New cards

What does a function with branches mean?

It contains if/else logic.

42
New cards

What does a function with loops mean?

It performs repeated operations inside the function.

43
New cards

What is unit testing for functions?

Testing each function individually with known inputs.

44
New cards

How does function execution work?

Control jumps to the function, runs it, then returns.

45
New cards

What is a common function error?

Forgetting to return a value from non-void functions.

46
New cards

What is pass-by-reference?

Parameters preceded by & allow modifying the original variable.

47
New cards

How do you modify a vector in a function?

Pass it by reference: void f(vector& v).

48
New cards

How do functions work with C strings?

C string parameters are char arrays, often passed as char[].

49
New cards

What is variable scope?

Where a variable can be accessed in the program.

50
New cards

What are default parameter values?

Parameters given a value in the function header if arguments are omitted.

51
New cards

What is function overloading?

Multiple functions with the same name but different parameters.

52
New cards

Explore top flashcards

BPH
Updated 628d ago
flashcards Flashcards (36)
Unit 7 Vocab
Updated 666d ago
flashcards Flashcards (24)
AMENDMENTS
Updated 231d ago
flashcards Flashcards (22)
Avancemos 2 U4.1
Updated 330d ago
flashcards Flashcards (37)
Monatomic ioons
Updated 802d ago
flashcards Flashcards (30)
The CNSS Model
Updated 259d ago
flashcards Flashcards (20)
chem stu guide 1
Updated 921d ago
flashcards Flashcards (80)
BPH
Updated 628d ago
flashcards Flashcards (36)
Unit 7 Vocab
Updated 666d ago
flashcards Flashcards (24)
AMENDMENTS
Updated 231d ago
flashcards Flashcards (22)
Avancemos 2 U4.1
Updated 330d ago
flashcards Flashcards (37)
Monatomic ioons
Updated 802d ago
flashcards Flashcards (30)
The CNSS Model
Updated 259d ago
flashcards Flashcards (20)
chem stu guide 1
Updated 921d ago
flashcards Flashcards (80)