Monday, June 24, 2013

Concepts of Programming Languages 10th Edition : Chapter 8

Created By : Robert W. Sebesta
Lecturer : Mr. Tri Djoko Wahjono, Ir. M.Sc
Answered by : Shirley Halim Ng
NIM : 1601233805
Class : 02PCT

Review Questions

1. What is the definition of control structure?
   => A control structure is a control statement and the collection of statements whose execution it controls.

3. What is the definition of block?
   => A block is a sequence of code, delimited by either braces or the do and end reserved words.

5. What are the design issues for selection structures?
   => The design issues for selection structures are :
- What is the form and the 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?

9. What are the design issues for multiple-selection statements?
   => The design issues for 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 handles, if at all?

15. What are design issues for counter-controlled loop statements?
    => The design issues for counter-controlled loop 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?

19. What does the range function in Phyton do?
    => Range function in Phyton takes one, two, or three parameters and it never returns the highest value in a given parameter range.

20. What contemporary languages do not include a goto?
    => Ruby

26. What is a user-defined iteration control?
    => A user-defined iteration control is a primary iteration that an alternative form that is in class by itself.



Problem Set

1. What design issues should be considered for two-way selection statements?
   =>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?

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.

14. State one of the main legitimate needs for gotos.
    => It is useful for programmer who wants to check errors in their program. Rather than fully modifying their code, they can put some goto statement inside the if statement and return the value of the error in case if an error happens.

No comments:

Post a Comment