Ranges, Switch Statements, and chars, strings & floating point numbers

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/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

How can you detect ranges implicitly in C++?

By using multi-branch if/else statements to check if a value falls within certain intervals.

2
New cards

What is a switch statement in C++?

A control structure that tests a variable against multiple constant values (cases) and executes the matching case's code block.

3
New cards

What is the purpose of the break statement in a switch?

It stops the execution of the current case and exits the switch statement to prevent fall-through.

4
New cards

What is switch case fall-through?

When a case does not have a break statement, and execution continues into the next case.

5
New cards

Can multiple cases share the same code in a switch statement?

Yes, multiple cases can be grouped together before a shared block of code.

6
New cards

How are char and string values compared in C++?

Using relational operators (==, !=, <, >, etc.); comparisons are based on ASCII or lexicographical order.

7
New cards

What does the .at() function do for strings?

Returns the character at a specific index in the string with bounds checking.

8
New cards

What does .size() or .length() return for a string?

The number of characters in the string.

9
New cards

What does .append() do for strings?

Adds another string or character(s) to the end of an existing string.

10
New cards

Why should you be careful when comparing floating-point numbers?

Because of rounding errors; use a tolerance (epsilon) to check if values are "close enough" instead of exactly equal.