C Control Flow Flashcards
(34 cards)
What is the default block in a C switch statement
a case block that is used to catch any input that does not match the case statements
C Control Flow: switch
Switch is a control flow statement that enables you to choose one course of action from a set of possible actions, based on the result of an integer expression
C Control Flow: do while
do while is a loop that executes a block of statements, then checks a condition and if it is true, the block is repeated, otherwise it will skip to the next statement after the condition
What three expressions does a C for loop contain
variable initialization, conditional expression, loop control variable expression
What does the break statement do in a C loop
It terminates the loop and program control returns to the next statement following the end of the loop
What does the continue statement do in a C loop
forces the next iteration of the loop and passes over any remaining statements within the loop
What is the controlling expression in a C switch statement
a constant integer expression followed by the switch keyword and is compared with each of the case labels
What is the body of a C switch statement enclosed in
Curly braces
C Control Flow: goto
Goto is a control flow statement that directs the flow of execution to a labelled block of code
What must the controlling expression be followed by in a C switch statement
A colon :
What does the break statement do in a C switch case block
skip over the other statements within that case and continue with whatever statement follows the closing brace
What is a continuation condition in C loops
A condition in a loop that is checked before each iteration to see whether the loop should continue
When does a C loop terminate
When the control expression evaluates to false
C Control Flow: for
For is a loop that executes a block of statements a given number of times
What are control expressions in C loops
conditions that control the operation of a loop
C Control Flow: if
the if statement is a selection statement that contains a block of code and executes them if the condition is true. if the condition is false, the block of code is not executed
C Control Flow: else
the else statement is a selection statement that contains a block of code and executes them if the condition in the corresponding if statement is false. it the condition is true, the else block is not executed
C Control Flow: else if
the else if statement is a selection statement that contains a block of code and executes them if the condition is true and the corresponding if statement evaluating a similar condition is false. if the condition is false the block is not executed
When is the if block executed
When the condition is true
When is the else if block executed
when the condition in the corresponding if statement is false and the condition in the else if statement is true
When is the else block executed
when the condition in the corresponding if statement is false
How are conditions formed
by using the equality and relational operators to make a boolean expression or by using a boolean value
What is a condition in C
a boolean expression used in selection statements and loops
What is a loop in C
a block of statements that execute repeatedly while a condition remains true