Chapter 8 Flashcards

1
Q

What is a control statement?

A

If, while, for, the word or boolean conjunction

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

What is a control structure?

A

The if, while, … including the block of code it runs. A set of control statements plus the body.

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

What is a two-way selection statement?

A

if ()
then…
else…

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

What are the design issues related to two-way selection statements?

A

-What is the form and type of the expression that controls the selection?
-How are the then and else clause specified?
-How should the meaning of nested selectors be specified?

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

How are nested selection statements handled in various languages?

A

-Java, C, C++, C# -> binds else to the nearest if statement, or use {}
-Ruby -> Use “end” to denote the end of each nested section

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

What is a multiple selection branch?

A

Allows for a selection between any number of statements or statement groups

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

What are the design issues related to multiple selection branches?

A

-What is the form and type of the expression that controls the selection?
-How are the selectable segments specified?
-Is execution flow through the structure restricted to include just a single selectable segment?
-How are the case values specified?
-How should unrepresented selector expression values be handled, if at all?

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

What are two different implementations of multiple selection branches?

A

-Switches
-Conds from Racket

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

What is an iterative structure?

A

A selection statement that repeatedly runs a block of code

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

What are the 3 main types of iterative structures?

A

Count controlled, logical controlled, user controlled. Or for, while, do-while.

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

What are the design decisions for these main types of iterative structures?

A

-Count controlled:
When is the loop variable evaluated?
What is the scope of the loop variable?
Can the user change the loop variable?
-Logic controlled:
Should the loop be pre or post test?
Should logically controlled loops use a different key word?
-User controlled:
Should the conditional mechanism be an integral part of the exit?
Should only one loop body be exited, or can enclosing loops also be exited?

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

What is an unconditional branch command?

A

Goto

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

Why is the goto command so dangerous?

A

-Difficult to trace
-Hard to write
-Leads to error-prone code

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