Chapter 8 Problems



CHAPTER 8 REVIEW QUESTIONS

1. What is the definition of control structure?
- a control structure is a control statement and the collection oh statements whose execution it controls.

2. What did Böhm and Jocopini prove about flowcharts?
- A selection statement provides the means of choosing between two or more execution paths in a program. Such statements are fundamental and essential parts of all programming languages, as was proven by Böhm and Jacopini.

3. What is the definition of block?
- In Ruby, a block is a sequence of code, delimited by either braces or the do and end reserved words. Blocks can be used with specially written methods to create many useful constructs, including iterators for data structures. This construct consists of a method call followed by a block. A block is actually an anonymous method that is sent to the method (whose call precedes it) as a parameter.

5. What are the design issues for selection structures?
- 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?

9. What are the design issues for multiple-selection statements?
- Some of the design issues for multiple selectors are similar to some of those for two-way selectors. For example, one issue is the question of the type of expression on which the selector is based. In this case, the range of possibilities is larger, in part because the number of possible selections is larger.

14. What are the design issues for all iterative control statements?
- The nature of the loop variable and the loop parameters provide a number of design issues. The type of the loop variable and that of the loop parameters obviously should be the same or at least compatible, but what types should be allowed?

15. What are the design issues for counter-controlled loop statements?
- The reserved word rec appears before the name of the function to indicate that it is recursive. The empty parentheses do nothing; they are there because in F# an empty statement is illegal and every if must have an else clause.

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?

14. State one of the main legitimate needs for gotos.
- In the past there was considerable debate in academia and industry on the merits of the use of goto statements. Use of goto was formerly common, but since the advent of structured programming in the 1960s and 1970s its use has declined significantly. The primary criticism is that code that uses goto statements is harder to understand than alternative constructions. Goto remains in use in certain common usage patterns, but alternatives are generally preferred if available.

1 comments :

Baccarat Rules | Rules for the Game Rules and Casino
The most basic casino game for blackjack. 메리트 카지노 쿠폰 The dealer 바카라 사이트 bets a total of five cards งานออนไลน์ in the order of the suit (blackjack, craps, & more).

Balas