Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.

Similar presentations


Presentation on theme: "Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6."— Presentation transcript:

1

2 Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6

3 Objectives To develop solution algorithms to eight typical programming problems using sequence, selection, and repetition constructs 6

4 Eight Solution Algorithms All the algorithms will use a combination of sequence, selection, and repetition constructs The algorithms have been designed to be interactive or to process sequential files (a) Defining the problem It is extremely important that you divide the problem into its three components: input, output, and processing 6

5 Eight Solution Algorithms (b) The control structures required Once the problem has been defined, write down the control structures (sequence, selection, and repetition) that may be needed, as well as any extra variables which the solution may require (c) The solution algorithm Having defined the problem and determined the required control structures, devise a solution algorithm and represent it using pseudocode 6

6 Eight Solution Algorithms Each solution algorithm presented in this chapter is only one solution to the particular problem: many different solutions could be equally correct (d) Desk checking You will need to desk check each of the algorithms with two or more test cases 6

7 Example 6.1 Process Number Pairs Design an algorithm that will prompt for and receive pairs of numbers from an operator at a terminal and display their sum, product, and average on the screen. If the calculated sum is over 200, an asterisk is to be displayed beside the sum A Defining diagram (see figure at top of page 70 in the textbook) 6

8 Example 6.1 Process Number Pairs B Control structures required 1.A DOWHILE loop to control the repetition 2.An IF statement to determine if an asterisk is to be displayed 3.Note the use of the NOT operand with the AND logical operator C Solution algorithm Refer to the algorithm written on page 70 of the textbook 6

9 Summary The approach to all of the problems followed the same path: 1.The problem was defined using a defining diagram 2.The control structures required were written down, along with any extra variables required 3.The solution algorithm was produced using pseudocode and the three basic control structures The solution algorithms mostly followed the same basic pattern 6


Download ppt "Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6."

Similar presentations


Ads by Google