Tuesday, June 25, 2013

Answers of Concepts of Programming Languages Chapter 8

Review Questions

1. A control structure is a control statement and the collection of statements whose execution it controls
2. Bohm and Jacopini proves that all algorithms that can be expressed by flowcharts can be coded in a programming language with only two control statements : one for choosing between two control flow paths and one for logically controlled iterations
3. Block is a sequence of code, delimited by either braces or the do and end reserved words.
4. The design issue of all the selection and iteration control statement is : should the control structure have multiple entries?
5. -
6. Python uses indention to specify compound statements and using a colon to introduce the then clause.
7. -
8. -
9. Design issues of multiple selection statements are :

  • 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?
10. -
11. The C switch statement has virtually no restrictions on the placement of the case expressions, whcih are treated as if they were normal statement labels.
12. C switch statement is based on ALGOL 68
13. C# has a static semantics rule that disallows the implicit execution of more than one segment. Beside, the control expression and the case statements can be strings in C#
14. Design issues of iterative statements are :
  • What are the type and scope of the loop variable?
  • Should it be legal for the loop variable or loop parameters to be changed in the loop, and if so, does the change affect loop control?
  • Should the loop parameters be evaluated only once, or once for every iteration?

Problem Set

1. Design issues of two way selection are 
  • 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?
2.-
3. The issue was that when a selection statement is nested in the then clause of a selection statement, it is not clear to which if an else clause should be associated.
Example :
      if (a
           if(a==0)
               a = 9;
      else
          b = 0;

No comments:

Post a Comment