





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The debate around the necessary control statements for programming languages beyond selection and logical loops. It covers the evolution of control structures, the issues surrounding their design, and various solutions such as fortran, algol 60, pascal, and ada. The document also discusses the advantages and disadvantages of different control structures and their impact on readability and flexibility.
Typology: Exercises
1 / 9
This page cannot be seen from the preview
Don't miss anything!






- C an select only a single statement;
IF (.NOT. condition) GOTO 20 ... ... 20 CONTINUE
if (boolean_expr) then begin ... end
ALGOL 60 if :
if (boolean_expr) then statement (the then clause) else statement (the else clause)
Example (Pascal)
if ... then if ... then ... else ...
ALGOL 60's solution - disallow direct nesting
if ... then if ... then begin begin if ... if ... then ... then ... end else ... else ... end
FORTRAN 77, Ada, Modula-2 solution – closing special words
Example (Ada)
if ... then if ... then if ... then if ... then ... ... else end if ... else
execution of the construct
switch (expression) { constant_expression_1 : statement_1; ... constant_expression_n : statement_n; [default: statement_n+1] }
Any number of segments can be executed in one execution of the construct (there is no implicit branch at the end of selectable segments)
Ada's case is similar to Pascal's case, except:
Example (Ada) if ... then ... elsif ... then ... elsif ... then ... else ...
end if
Design Issues
control
Ada Design choices
-C Design Choices
- Design Issues 1. Pre-test or post-test? 2. Should this be a special case of the counting loop statement (or a separate statement)?
- Design issues 1. Should the conditional be part of the exit? 2. Should the mechanism be allowed in an already controlled loop? 3. Should control be transferable out of more than one loop? 1. C , C++, and Java - break - Unconditional; for any loop or switch; one level only (Java’s can have a label) - There is also a continue statement for loops; it skips the remainder of this iteration, but does not exit the loop