C Control Flow Flashcards

1
Q

What is the default block in a C switch statement

A

a case block that is used to catch any input that does not match the case statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

C Control Flow: switch

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

C Control Flow: do while

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What three expressions does a C for loop contain

A

variable initialization, conditional expression, loop control variable expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the break statement do in a C loop

A

It terminates the loop and program control returns to the next statement following the end of the loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the continue statement do in a C loop

A

forces the next iteration of the loop and passes over any remaining statements within the loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the controlling expression in a C switch statement

A

a constant integer expression followed by the switch keyword and is compared with each of the case labels

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the body of a C switch statement enclosed in

A

Curly braces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

C Control Flow: goto

A

Goto is a control flow statement that directs the flow of execution to a labelled block of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What must the controlling expression be followed by in a C switch statement

A

A colon :

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the break statement do in a C switch case block

A

skip over the other statements within that case and continue with whatever statement follows the closing brace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a continuation condition in C loops

A

A condition in a loop that is checked before each iteration to see whether the loop should continue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When does a C loop terminate

A

When the control expression evaluates to false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

C Control Flow: for

A

For is a loop that executes a block of statements a given number of times

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are control expressions in C loops

A

conditions that control the operation of a loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

C Control Flow: if

A

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

17
Q

C Control Flow: else

A

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

18
Q

C Control Flow: else if

A

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

19
Q

When is the if block executed

A

When the condition is true

20
Q

When is the else if block executed

A

when the condition in the corresponding if statement is false and the condition in the else if statement is true

21
Q

When is the else block executed

A

when the condition in the corresponding if statement is false

22
Q

How are conditions formed

A

by using the equality and relational operators to make a boolean expression or by using a boolean value

23
Q

What is a condition in C

A

a boolean expression used in selection statements and loops

24
Q

What is a loop in C

A

a block of statements that execute repeatedly while a condition remains true

25
Q

What are infinite loops in C

A

Loops that never end

26
Q

C Control Flow: while

A

the while statement is a loop that executes a block of statements repeatedly as long as the condition is true

27
Q

when does a C while loop execute

A

when the condition is true

28
Q

when does a C while loop not execute

A

when the condition is false

29
Q

when does a C while loop end its execution

A

when the condition becomes false

30
Q

when does a C for loop execute

A

when the condition is true

31
Q

when does a C for loop not execute

A

when the condition is false

32
Q

when does a C for loop end its execution

A

when the condition becomes false

33
Q

How long does a C while loop execute

A

As long as the condition is true

34
Q

How long does a C for loop execute

A

As long as the condition is true