CSC 351 - Chapter 8 Flashcards
selection statement
provides a way of choosing between two or more execution paths
control structure
a control statement and the collection of statements whose execution it controls
multiple-selection statement
allows the selection of one of any number of statements ( switch statement)
iterative statement
causes a statement to be executed zero, one or more times. often called a loop
loop variable
where the count value is maintained
how do functional languages control repetition?
instead of iteration, they use recursion
what is a block?
is a sequence of code that can be used with specially written methods to create useful constructs
selection statement design issues
- what is the form and type of the expression that controls the selection?
- how are the then and else clauses specified?
- how should the meaning of nested selectors be specified?
iterative counter-controlled statement design issues
- what are the type and scope of the loop variable?
- should it be legal for the loop variable/parameters to be changed in the loop?
- should the parameters be evaluated only once, or once for every iterations?
solution for nesting two-way selectors
use a static semantics rule rather than a syntatic entity
iterative statement design issues
- how is iteration controlled?
- where should the control mechanism appear in the loop
multiple selection statement design issues
- 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?
- how are the case values specified?
- how should unrepresented selector expression values be handled?
pretest loop
the test for loop completion occurs before the loop body is executed
posttest loop
the test for loop completion occurs after the loop body is executed
logically controlled loops design issues
- should the control be pretest or posttest?
- should the logically controlled loop be a special form of a counting loop or a separate statement?