- 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 the pseudocode. Print is usually used when the output is to be sent to the printer, while Write is 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 the pseudocode. An output Prompt instruction is usually required before an input Get instruction. The Prompt verb is used when information is sent to the screen, which requires the user to respond, usually by providing input.
- A computer can perform arithmetic
A computer can perform some sort of mathematical calculation, or apply a formula. Programmer can use actual mathematical symbols or the words for those symbols. For example:
add number to total
total = total + number
The symbols that can be used in pseudocode are listed below:
+ for add
for subtract
for multiply
/ for divide
( ) for parentheses
The verbs Compute and Calculate are also used in pseudocode. Moreover, The equal symbol ‘=’ is used to indicate assignment of a value as a result of some processing.
- A computer can assign a value to a variable or memory location
There are three instances in which you may write pseudocode to assign a value to a variable or memory location:
- The verbs Initialise or Set are used to give data and initial value in pseudocode.
- The symbols “=” or “←” are used to assign a value as a result of some processing.
- The verbs Save or Store are use to keep a variable for later use.
- A computer can compare two variables and select one of two alternative action
The special keyword IF, THEN and ELSE are used to compare two variables and then, as a result of the comparison, select one of two alternative actions. The comparison of data is established in the IF clause, and the choice of alternatives is determined by the THEN or ELSE options. Only one of these alternatives will be performed.
- A computer can repeat a group of actions
By using two special keywords, DOWHILE and ENDDO, computer can repeat a group of actions. The DOWHILE and ENDDO statement perform the action in their bodies zero or more times. If the loop continuation condition is initially false, the action will not execute. This statement performs the action or group of actions in its body at least once.
In order to solve the problem, programmers need to define the problem. Defining the problem need to be read and reread carefully to understand the requirement. To define the problem, input, processing and output are divided into three separate components:
- Input is a list of the source data provided to the problem.
- Output is a list of the outputs required.
- Processing is a list of actions needed to produce the required outputs.
When reading the problem statement, the input, output and processing components are easily to identify. The input and output can be defined as nous and adjectives. And the processing component can be defined as verbs and adverbs.
After the problem is defined, the next step is designing a solution algorithm. This is the most challenging task in the life cycle of a program. Defining a solution algorithm consists of 4 steps:
- Give a name to the algorithm. The name of algorithm should be meaningful and describe the function of the algorithm. For Example: Find_average _tempature, Calculate_mowing_time, Calculate_payroll.
- An END statement at the end of the algorithm indicates that the algorithm is complete.
- All processing steps between the algorithm name and the END statement have been indented for readability.
- Each processing step in the defining diagram relates directly to one or more statements in the algorithm.
Reference:
- Simple Program Design: A Step by Step Approach, Chapter 2, 5e by Lesley Anne Robertson.
- Simple Program Design: A Step by Step Approach, Chapter 3, 5e by Lesley Anne Robertson