5. Development of Algorithm- pseudocodes

Development of Algorithm- manyamfranchise.com

Development of algorithms

Development of algorithms can be defined as logical steps that a program follows in order to solve a problem.

Various tools are used to depict algorithms. They include:

- Decision trees

- Decision tables

- Flowcharts and

- Pseudo codes

Pseudo codes

A pseudo code is a set of statements written in a human readable language but expressing the processing logic of a program.

- Pseudo codes are not executable by the computer

Guidelines for designing a good pseudo code

To design a good pseudocode, proceed as follows

  1. The statement must be short, clear and readable
  2. The statements must not have more than one meaning i.e. should be unambiguous
  3. The pseudo code lines should be clearly outlined and indented clearly
  4. A pseudo code should show clearly the start and stop of executable statements and the control structures (to be discussed later in the section)
  5. The input, output and processing statements should be clearly stated, using keywords such as

Several keywords are often used to indicate common input, output, and processing operations.

Input:          READ, OBTAIN, GET
Output:         PRINT, DISPLAY, SHOW
Compute:        COMPUTE, CALCULATE, DETERMINE
Initialize:     SET, INIT
Add one:        INCREMENT, BUMP

Example:

Write a pseudo code that can be used to prompt the user to enter the diameter of a circle which will be used to calculate the perimeter and area of the circle

Answers

 Start
PRINT “enter diameter parameter”
       READ D
PERIMETER = 22/7*D
AREA = 22/7*D/2*D/2
PRINT PERIMETER
PRINT AREA
Stop

Trial Questions

1. Write a pseudo code that can be used to prompt the user to enter two numbers, calculate the sum and average of the two numbers and then display the output on the screen

2. Write a structured algorithm that would prompt the user to enter the length and width of a rectangle, calculate the area and perimeter then display the result

3. Write a pseudo code for a program that can be used to classify people according to the age limit. If a person is more than 20 years; output “adult” else output “young person”

4. What factors do you consider when designing a good pseudo code

5. What is the importance of writing algorithms

READ MORE: http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html

<<PREVIOUS | NEXT>>

5.1-FlowChart — 03-Aug-2014 10:39:26