Lesson 8 Flashcards
FORTRAN I control statements are based on
IBM 704 hardware
RESULT OF THE CONTROL STATEMENTS IN THE FORTRAN I EVOLUTION:
All algorithms represented by the flowcharts can be coded with only two way selection statements and pretest loops.
CONTROL STRUCTURE
It is a statement and the statments that it controls.
What is the issue with the design of the control structure?
Can a control structure have multiple entries?
Two general categories of the selection statements
Two way selection
Multiple selection
What are the design issue with the two way selection statements?
What is the form and type of the control expression?
How are the then and the else clause specified?
How should the meaning of the nested selectors be specified?
When is the control expression placed in the parenthesis?
When the then reserved word or any other syntactic marker is not used.
Languages that have the control expression as arithmetic
C89, C99, C++, Python
Perl has clauses delimited by braces. T/F
T
The clause form in the ruby and the python is
Statement Sequences
Semantic rule for the Java nested if
the else clause resonant or matches with the nearest if.
AN laternative format to the semantic rule for the Java nested if is used, in which the compund statements are used. Which languages accept this solution?
Java, C, C sharp, C++
Which programming language does not allow else-less if statements?
ML
In ML, F sharp, Lisp, the selector is an expression. What is the rule for the type of value returned by then and else clause?
They should be of the same type.
What are the design issues with the multiple selection statements?
form and type of the control expression
selectable segments specified
is the execution flow through the structure restricted to include just a single slectable segment
cases values specified
What is done about the unrepresented expression values
The programming languages that allow the multiple selection statement:
C, C++, Java, and JavaScript
What are the design choices for C’s switch statement?
Control and constant expressions are of discreet type (int, char, enum); selectable segments can be statement sequences, bloacks or compound statements; Any number of segments can be executed in the execution of the construct; Default is for the unrepresented values; No restriction on the case expr.
What are the design choices for the C sharp’ s multiple selection statements?
Has static semantics ( disallows the implicit execution of more than one segment)
each selecatble segment ends with break or goto
the control expr and the case constants can be strings
Ruby’s multiple selections statement form:
case
when boolean expr then expr
……
when boolean expr then expr
[else expr]
end