2.1 How to write pseudocode
When designing a solution algorithm,you need to keep in mind that a computer will eventually perform the set of instructions written. That is if you use words and phrases in the pseudocode which are in line with basic computer operations the translation from the pseudocode algorithm to a specific programming language becomes quite simple.
This chapter establishes six basic computer operations and introduces common words and keywords used to represent these operations in pseudocode. Each operation can be represented as a straightforeard English instruction, with keywords and indentation to signify a particular control structure.
Six basic compter operations
1 A computer can receive in information
When a computer is required to receive information or input from a particular source,Whether it be a terminal,a disk or any other device,the verbs Read and Get are used in pseudocode . Read is usually used when the algorithm is to receive input from a record on a file,While Get is used when the algorithm is to receive input from the keyboard. For example , typical pseudocode instructions to receive information are :
Read student name
Get system date
Read number¬_1,number_2
Get tax_code
Each example used a single verb , Read or Get , followed by one or more nouns to be obtainted.
2 A computer can put out information
When a computer is required to supply information or output to a device,the verbs Print,Write,Put,Output or Display are used in pseudocode. Print is usually used when the output is to be written to a file . If the output is to be written to the screen , the words Put ,Output or Display are used in pseudocode . Typical pseudocode examples are :
Prit ‘Program Completed’
Write customer record to master file
Put out name,addess and pseudocode
Output total_tax
Display ‘End of data ‘
Chapter summary