PSEUDOCODE AND FLOWCHARTS
What is pseudocode?
Pseudocode is an easy and clear/straightforward way to represent an algorithm. Data items are processed need to be given names, same way as variables so you don’t get confuse between data types. Pseudocode can be used to design and program apps and other software, it is a good way to design and test by doing a dry run to see if your design works. A dry run is basically the test of the program to see if it works.
Atomic Type names:
- INTEGER – A whole number
- REAL – A number capable of containing a fractional part
- CHAR – A single character
- STRING – A sequence of zero or more characters
- BOOLEAN – The logical values are TRUE and FALSE
Conditional Statements
When different actions are preformed by an algorithm according to the values of the variables, conditional statements can be used to decide which action should be taken. Examples of them are IF, ELSE, CASE, OF, OTHERWISE however when you use it you need to end it such as ENDIF.
e.g.
IF Age < 18
THEN PRINT “Child”
ELSE PRINT “Adult”
ENDIF
A choice between different values: CASE…OF…OTHERWISE
Example:
CASE Grade OF // this is a function set for grades
“A” : PRINT “Excellent” //if you got an A, it will print excellent
“B” : PRINT “Good” // if you got a B, it will print good
“C” : PRINT “Average” //if you got a C, it wil print average
OTHERWISE PRINT “Imporovement is needed” //if you got lower, it will print improvement needed
ENDCASE //ends the funtion
Activity 10.2
Example of an algorithm.
How I would test if this algorithm works is by doing a dry run.
A questionnaire based algorithm. // represents the dry run.
Flowcharts:
While cards: AND, OR, NOT, LIKE.
While cards are the only controls that need all caps.