1/26
Flashcards covering selection, iteration, and jump statements in C++ conditional control structures, based on lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are the three major categories of conditional control structures in C++?
Selection statements, Iteration statements, Jump statements.
Name the selection statements available in C++.
If statement, If Else Statement, If Else If statement, Nested If statement, Switch statement.
What is the purpose of control structures in programming?
To alter the flow of program execution based on conditions, enabling decision making.
What are iteration statements also known as?
Loops or looping statements.
List the three kinds of loops in C++.
For loop, While loop, Do While loop.
What is an If statement used for?
To execute a set of statements when the condition evaluates to true.
What is the syntax of an If statement?
if (expression) { Statements }.
What happens when the condition in an If statement is true?
The statements inside the if block execute.
What is an If Else statement?
A conditional branching statement that executes the 'if' part when true, otherwise executes the 'else' part.
What is the syntax of If Else?
if (expression) { Statements } else { Statements }.
What is an If Else If statement?
An extension of If Else to check additional conditions when previous ones are false.
What is the syntax of If Else If?
if (expression) { Statements } else if (expression) { Statements } else if (expression) { Statements }.
What is a Nested If statement?
An if statement placed inside another if statement to check multiple conditions.
What is a Switch statement and its behavior?
Switch compares an expression against case constants and executes the matching case; uses break to end a case; default runs if no match.
What is the syntax of a Switch statement?
switch (expression) { case constant: Statements break; … default: Statements; break; }.
What is a For loop?
An iteration that runs a block of code with initialization, condition, and increment: for (init; condition; increment) { … }.
What is a While loop?
An entry-controlled loop that executes while the condition is true.
What is a Do While loop?
An exit-controlled loop that executes the block at least once, then tests the condition.
What is a Return statement?
Stops execution of a function and returns control to the caller; may return a value if the function is non-void.
What is a Goto statement used for?
Unconditional transfer of control to a labeled statement elsewhere in the code.
What is the exit() function in C++?
Terminates program execution and returns a code to the OS; 0 indicates success, non-zero indicates error.
What is the Break statement and where is it used?
Break terminates the current loop or switch case immediately.
What is the Continue statement used for?
Skips the rest of the current loop iteration and continues with the next iteration.
What is the difference between break and continue?
Break ends the loop or switch entirely; continue skips to the next iteration within the same loop.
What is an entry controlled loop?
A loop (like while) that tests the condition before each iteration.
What is an exit controlled loop?
A loop (like do-while) that tests the condition after the iteration.