# 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

` ``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

#### 5.1-FlowChart

posted Aug 3, 2014, 3:39 AM by Maurice Nyamoti   [ updated May 11, 2015, 9:20 AM ]

# Flow Charts

Flow charts are used to represent any well defined sequence of activities. they are used to convey in diagrammatic form, the logic, processing operations and flow of control required of a computer program

## Uses Of Flowcharts

Flowcharts are used by programmers to:

1. To plan the structure of a program before it is written
2. To describe the structure of a program after it has been written

## Flowchart Symbols

Flowchart symbols are combined with short text clues which are a form of shorthand understood by programmers. Below is a list of symbols:
 Symbol Meaning 1- Start/Stop Ellipse: denotes the beginning and end of the program algorithm 2- Input/Output Parallelogram: used to denote an input or output operation. For example, READ A, B, PRINT SUM 3- Process Rectangle: Indicates that a processing or data transformation is taking place. For example SUM = A+B 4- Decision Rhombus: Used to specify a condition. A condition must evaluate to a Boolean value (true or false) for the program to execute the next instructions 5- Connector Circle: Used as a connecting point or interface for arrows coming from different directions 6- Arrow Arrow: Used to indicate the direction of flow of the program logic

## Guidelines For Drawing a Flowchart

1. there should be only one entry/starting point and one exit point of the program algorithm - except for decisions and connectors
2. Use the correct symbol at each stage in the flowchart
3. The logical flow should be clearly shown using arrows.
4. Use connectors to reduce the number of flow-lines
5. Add notes if necessary, but don't clutter the diagram
6. Lines should ideally be vertical or horizontal

1-1 of 1