Name : Fandy Limardi
NIM : 1601210713
Lecture : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment : Concept of programming languages ---- Chapter 8 Statement-Level Control Structures
Review
Questions
1. What is the definition of
control structure?
structure is a control statement and the collection
of statements whose execution it controls.
2. What did Bohm and Jocopini prove about
flowcharts?
they proved that all algorithms that can
be expressed by flowcharts can be coded in a programming languages with only
two control statements: one for choosing between two control flow paths and one
for logically controlled iterations.
3. What is the definition of block?
Block is a sequence of code delimited by
either braces or the do and end reserved words.
7. Under what circumstances must an F# selector
have an else clause?
An F# selector have an “else”
clause if the “if” expression does return a value.
12. On what
previous language was C’s switch statement based?
The ability to have control flow from one selectable segment to another is rarely used. C’s switch is modeled on the multiple-selection statement in ALGOL
68, which also does not have implicit branches from selectable segments
The ability to have control flow from one selectable segment to another is rarely used. C’s switch is modeled on the multiple-selection statement in ALGOL
68, which also does not have implicit branches from selectable segments
14. What
are the design issues for all iterative control statements?
- How is the iteration controlled?
- Where should the control mechanism appear in the loop statement?
21. What
are the design issues for all iterative control statements?
- How is the iteration controlled?
- Where should the control mechanism appear in the loop statement?
22. What is the main reason
user-located loop control were invented?
It is convenient for a programmer to choose a location for loop control other than the top or bottom of the loop body. As a result, some languages provide this capability. A syntactic mechanism for user-located loop control can be relatively simple, so its design is not difficult. Such loops have the structure of infinite loops but include user-located loop exits.
It is convenient for a programmer to choose a location for loop control other than the top or bottom of the loop body. As a result, some languages provide this capability. A syntactic mechanism for user-located loop control can be relatively simple, so its design is not difficult. Such loops have the structure of infinite loops but include user-located loop exits.
23. What are the design issues for user-located loop control mechanisms?
The design issues for such a mechanism are the following:
• 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?
The design issues for such a mechanism are the following:
• 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?
26. What is a user-defined iteration
control?
A user-defined
iteration control is the one that issues a special call to the iterator, in which the
iterator is called at the beginning of each iteration, and each time it is
called, the iterator returns an element from a particular data structure in
some specific order.
Problem
Set
1. What design issues should ne considered for
two-way selection statements?
The design issues for two-way selectors can be summarized as follows:
The design issues for two-way selectors can be summarized as follows:
·
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?
4. What are the limitations of implementing a
multiple selector from two-way selectors and
gotos?
gotos?
A multiple selector can be built
from two-way selectors and gotos, but the resulting structures are cumbersome,
unreliable, and difficult to write and read.
5. What are the arguments , pro and con, for
Java’s approach to specify compound statements in control statements?
·
Compound
statements are required in control statements when the body of the if or else
clause requires multiple statements.
clause requires multiple statements.
·
Java
uses braces to form compound statements, which serve as the bodies of if and else
clauses.
clauses.
11. Explain the advantages and disadvantages of the
Java switch statement, compared to C++’s switch statement.
The Java variable in the argument of a switch statement can be
of type integral ( byte, short etc.), char and String( JDK 1.7 onwards),
whereas in C++ the argument can be int or char.
No comments:
Post a Comment