Pseudocode flowcharts


Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Pseudocode flowcharts

  1. 1. Pseudocode For Program Design 1
  2. 2. Flowcharts vs PseudocodeFlowcharts were the first design tool to bewidely used, but unfortunately they do notreflect some of the concepts of structuredprogramming very well. Pseudocode, on the other hand, is a newer tooland has features that make it more reflective ofthe structured concepts.The drawback is that the narrative presentationis not as easy to understand and/or follow. 2
  3. 3. Rules for PseudocodeWrite only one statement per lineCapitalise initial keywordIndent to show hierarchy and structuresEnd multiline structuresKeep statements language independent Remember you are describing a logic plan to develop a program, you are not programming! 3
  4. 4. One Statement Per LineEach statement in pseudocode should expressjust one action for the computer. Note capitals for the initial keywords Pseudocode READ name, hoursWorked, payRate gross = hoursWorked * payRate WRITE name, hoursWorked, grossThese are just a few of the keywords to use,others include READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE 4
  5. 5. Indent to Show HierarchySequence: Keep statements in sequence all starting in the same columnSelection: READ name, grossPay, taxes IF taxes > 0 IF, ELSE (or ELSEIF), ENDIF net = grossPay – taxes must be in line ELSE Indent all statements that depend net = grossPay on a condition ENDIFLoop: WRITE name, net count = 0 WHILE, ENDWHILE WHILE count < 10 Indent statements that fall inside ADD 1 to count the loop but not keywords that WRITE count form the loop ENDWHILE Also REPEAT, UNTIL WRITE “The End” 5
  6. 6. The Selection Structure yes no amount < 100interestRate = .06 interestRate = .10 IF amount < 100 interestRate = .06 Pseudocode  ELSE InterestRate = .10 ENDIF 6
  7. 7. The Looping StructureIn flowcharting one of the more confusing thingsis to separate selection from looping. This isbecause each structure use the diamond as theircontrol symbol.Pseudocode avoids this by using specifickeywords to designate looping WHILE / ENDWHILE: condition checked before loop REPEAT / UNTIL: condition checked after loop 7
  8. 8. WHILE / ENDWHILE Start count = 0 WHILE count < 10 ADD 1 to count count = 0 WRITE count ENDWHILE WRITE “The End” count Mainline <10  Modular count = 0 Write WHILE count < 10 add 1 to “The End” count DO Process ENDWHILE Stopwrite count WRITE “The End” Process ADD 1 to count WRITE count 8
  9. 9. REPEAT / UNTIL Start count = 0 REPEAT count = 0 ADD 1 to count WRITE count UNTIL count >= 10 add 1 to WRITE “The End” count Mainline  Modular write count count = 0 REPEAT DO Process count <10 UNTIL count >= 10 WRITE “The End” Write Process“The End” ADD 1 to count Stop WRITE count 9
  10. 10. Flowchart vs PseudocodeFlowchart Advantages: Pseudocode Advantages Standardized Easily modified Visual Implements structured concepts Done easily on Word ProcessorFlowchart Disadvantages: Pseudocode Hard to modify Disadvantages: Structured design elements Not visual not implemented No accepted standard, varies Special software required from company to company 10
  11. 11. Access of DataThe READ statement tells the computer to get avalue from an input device and store it in a memorylocation. How to deal with memory locations which have been allocated an address e.g. 19087Give them names (field or variable names) Using descriptive words e.g. Total as opposed to a location addresses 11
  12. 12. Rules for Variable NamesBegin with lowercase letterContain no spacesAdditional words begin with capitalUnique names within codeConsistent use of names 12
  13. 13. Working with Fields Calculations Selection+ add > greater than- subtract < less than* multiply = equal to/ divide >= greater than or equal to** or ^ exponentiation <= less than or equal to() grouping <> not equal to 13