Download presentation
Presentation is loading. Please wait.
Published bySara Candice Curtis Modified over 9 years ago
1
1 Pseudocode For Program Design
2
22 Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures End multiline structures Keep statements language independent Remember you are describing a logic plan to develop a program, you are not programming!
3
33 One Statement Per Line Each statement in pseudocode should express just one action for the computer. Note capitals for the initial keywords These are just a few of the keywords to use, others include READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE Pseudocode READ name, hoursWorked, payRate gross = hoursWorked * payRate WRITE name, hoursWorked, gross Pseudocode READ name, hoursWorked, payRate gross = hoursWorked * payRate WRITE name, hoursWorked, gross
4
44 Indent to Show Hierarchy Sequence: Keep statements in sequence all starting in the same column Selection: IF, ELSE (or ELSEIF), ENDIF must be in line Indent all statements that depend on a condition Loop: WHILE, ENDWHILE Indent statements that fall inside the loop but not keywords that form the loop Also REPEAT, UNTIL READ name, grossPay, taxes IF taxes > 0 net = grossPay – taxes ELSE net = grossPay ENDIF WRITE name, net READ name, grossPay, taxes IF taxes > 0 net = grossPay – taxes ELSE net = grossPay ENDIF WRITE name, net count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The End” count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The End”
5
55 The Looping Structure Pseudocode uses specific keywords to designate looping WHILE / ENDWHILE: condition checked before loop REPEAT / UNTIL: condition checked after loop
6
66 WHILE / ENDWHILE count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The End” REPEAT / UNTIL count = 0 REPEAT ADD 1 to count WRITE count UNTIL count >= 10 WRITE “The End”
7
77 Multiple Decisions Example: the postage charged by Nation Couriers is Calculated on the weight of the parcel. < 2 kg$4.50 2 – 5 kg$4.50 + $1 per kg over 2 kg > 5 kg$8 + $1 per kg over 5 kg READ weight CASE weight OF less than 2 : cost = $4.50 between 2 and 5 : cost = $4.50 + (weight – 2) greater than 5 : cost = $8 + (weight -5) END CASE PRINT cost
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.