6599 words - 26 pages

Booklet 3

This covers the following topics found in section 3 of the computer studies syllabus: Item Topic Page numbers 1 Common flowchart symbols 2 2 Writing flowcharts to solve problems 3 3 Dry running of flowcharts 9 4 Problems based on flowcharting 13 5 Pseudocode 18 6 Writing algorithms using pseudocode 20 7 Problems based on pseudocode 25 8 Introduction to logic 28 9 Description of common logic gates 28 10 Combinations of logic gates 31 11 Problems based on logic 34

1

Booklet 3 covers the development of algorithms (both in pseudocode and flowchart form) and also introduces logic gates which is a new topic from 2011. Introduction to Flowcharts This section covers the use of flow diagrams (charts) in the production of algorithms. Systems flowcharts are different and these are covered in a different section (Systems analysis). The early part of section 3.1 (i.e. top down design, structure diagrams, menus, libraries of procedures and subroutines) is covered adequately by standard text books. This section primarily covers four areas: 1 Common flow chart symbols 2 Writing flowcharts to solve problems 3 Dry running of flowcharts to determine its function and outputs 4 Exercises to test the above concepts 1 Common flowchart symbols 1.1 The start and end box:

START

END

1.2 The process box:

X = X + 1

1.3 Input/Output box:

Print X

1.4 Decision/query box:

No YesIs X > 5?

2

2 Writing flowcharts to solve problems

The following five problems are also covered in section 3.2 where the algorithms are constructed using pseudocode. Candidates may choose to answer questions using either flowcharts or pseudocode but a working knowledge of both techniques is well advised.

2.1 Example 1

A town contains 5000 houses. Each house owner must pay tax based on the value of the house. Houses over $200 000 pay 2% of their value in tax, houses over $100 000 pay 1.5% of their value in tax and houses over $50 000 pay 1% of their value in tax. All others pay no tax. Write an algorithm to solve this problem in the form of a flowchart.

2.2 Example 2 The following formula is used to calculate n: n = (x * x)/(1 - x). The

value x = 0 is used to stop the algorithm. The calculation is repeated using values of x until the value x = 0 is input. There is also a need to check for error conditions. The values of n and x should be output. Write an algorithm to show this repeated calculation in the form of a flowchart.

2.3 Example 3 Write an algorithm in the form of a flowchart which takes temperatures

input over a 100 day period (once per day) and outputs the number of days when the temperature was below 20C and the number of days when the temperature was 20C and above.

2.4 Example 4 Write an algorithm in the form of a flowchart which:

• inputs the top speeds (in km/hr) of 5000 cars • outputs the fastest speed and the slowest speed • outputs the average (mean) speed of all the 5000 cars

2.5 Example 5 A shop sells books, maps and magazines. Each item is identified by a...

Get inspired and start your paper now!