Pseudocode-the concept
Pseudocode-the concept
Pseudocode-the concept
Pseudocode
Flowcharts were the first design tool to be widely used, but unfortunately they do not reflect some of the concepts of structured programming very well. Pseudocode, on the other hand, is a newer tool and has features that make it more reflective of the structured concepts. The drawback is that the narrative presentation is not as easy to understand and/or follow.
Rules for Pseudocode
Write only one statement per line
Capitalize initial keyword
Indent to show hierarchy
End multiline structures
Keep statements language independent
One Statement per Line
Each statement in pseudocode should express just one action for the computer. If the task list
is properly drawn, then in most cases each task will correspond to one line of pseudocode.
Task List Pseudocode
Read name, hours worked, rate of pay READ name, hours Worked, pay Rate
Perform calculations
gross = hours worked * rate of pay gross = hours worked *pay rate
Write name, hours worked, gross WRITE name, hours Worked, gross
Capitalize Initial Keyword
In the example below note the words: READ and WRITE. These are just a few of the keywords to use, others include:
READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE
Pseudocode
READ name, hours Worked, pay Rate
gross = hours Worked * pay Rate
WRITE name, hours Worked, gross
Indent to Show Hierarchy
Sequence: Keep statements in sequence all starting in the same column
Selection: Indent statements that fall inside selection structure, but not the keywords that form the selection
Loop: Indent statements that fall inside the loop but not keywords that form the loop
Each design structure uses a particular indentation
READ name, gross Pay, taxes
IF taxes > 0
net = gross Pay taxes
ELSE
net = gross Pay
ENDIF
WRITE name, net
End Multiline Structures
See the IF/ELSE/ENDIF as constructed above, the ENDIF is in line with the IF.
The same applies for WHILE/ENDWHILE etc
Language Independence
Resist the urge to write in whatever language you are most comfortable with, in the long run you will save time. Remember you are describing a logic plan to develop a program, you are not programming!
The Looping Structure
In flowcharting one of the more confusing things is to separate selection from looping. This is because each structure uses the diamond as their control symbol. In pseudocode we avoid this by using specific keywords to designate looping
WHILE/ENDWHILE
REPEAT/UNTIL
Advantages & Disadvantages
Flowchart Advantages:
Standardized
Visual
Pseudocode Advantages
Easily modified
Implements structured concepts
Done easily on Word Processor
Flowchart Disadvantages:
Hard to modify
Structured design elements not implemented
Special software required
Pseudocode Disadvantages:
Not visual
No accepted standard, varies from company to company
Access of Data
The READ statement tells the computer to get a value from an input device and store it in a memory location. Memory locations are identified by their addresses, we give them names (field names / variable names) using words descriptive to us such as ctr as opposed to allocation addresses such as 19087.
Rules for Variable Names
Begin with lowercase letter
Contain no spaces
Additional words begin with capital
Unique names within code
Consistent use of names
Working with Fields
Calculations
+ add
- subtract
* multiply
/ divide
** or ^ exponentiation
( ) grouping
Selection
> greater than
< less than
= equal to
>= greater than or equal to
Barcode Verification is Important Sending Sweet Treats For All Occasions with Mrs. Beasley's Coupon Codes Carrot Ink Coupon Codes: Print More, Spend Less The Chicago Code Season 1 Episode 7 Black Hand and the Shotgun Man Plock Cheats Code (HOT) Basics Of Discount Coupons And Promo Codes Spend less with Cut price Voucher Codes! Resort World Cheats Code (HOT) Benefits and Method of ANSI to Unicode PST Conversion Sift And Toss Kitty Litter Liners Save with Promo Codes Sift And Toss Litter Box Liners Save with Coupon Codes Shop easier with discount codes The Benefits of Police Scanner Codes