1/14
Vocabulary and concepts regarding C++ decision-making control statements including if-else structures and switch cases.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Decision Making (Selection) Statements
Programming logic that evaluates a condition (true/false) to direct the flow of execution to specific blocks of statements.
if Statement
A control statement where a block of code is executed only if the specified condition evaluates to true (non-zero).
if-else Statement
A selection statement that executes one block of code if a condition is true and a different block if the condition is false.
Nested if Statement
An if or if-else statement placed inside another if or if-else statement, used when a decision depends on the outcome of a previous decision.
if-else-if Ladder
A structure used to check multiple conditions in sequence; the first true condition's block executes and the remaining blocks are skipped.
switch Statement
A multi-way decision-making statement that tests the value of an expression against a list of constant case values to execute a matching block.
break Statement
A command used to terminate the switch block; if omitted, execution 'falls through' into the subsequent case.
default Case
An optional block in a switch statement that executes only when none of the constant case labels match the expression's value.
Valid switch Expression Data Types
Data types including "int", "char", and "enum" that can be used in a switch statement; "float", "double", and "string" are not supported.
Fall-through
A situation in a switch statement where execution continues into the next case because a break statement was omitted.
Dangling else Problem
An ambiguity where it is unclear which "if" an "else" belongs to; resolved in C++ by associating the "else" with the nearest unmatched "if" or using braces .
Conditional (Ternary) Operator
A shorthand way of writing a simple if-else statement using the syntax "condition?expression1:expression2".
Leap Year Rule
A year is a leap year if it is divisible by 4, but century years must also be divisible by 400.
Relational Operators
Symbols like >, <, and >= used in if-else-if ladders to check for ranges (e.g., marks >=60) which are not directly supported by switch statements.
Logical Operators
Operators such as "&&" (AND) and "||" (OR) used within selection statements to combine multiple conditions.