Professional Documents
Culture Documents
- What is a computer?
- Accept data, as input
- Process the data
- Store data and information
- Produce information, as output.
- Input parts/devices
Examples include Keyboard, mouse etc.
- Process part/device
For example CPU or Systems Unit.
- Output parts/ devices
Examples include Monitor, Printer etc.
- Storage parts/devices
For example Flash disk, Memory card etc.
ALGORITHMS.
- A flow chart can be considered as an example of an Algorithm
Definition
- An algorithm is generally a set of logical steps that need to be followed in order to solve a
problem.
- For example the solving of a malaria problem using any anti-malaria drug.
FLOW CHARTS
- The underlying factors of any flow chart are the use of the correct symbols for each step
and the correct operation symbols.
- BEGIN
For example; calculate how far point A is from CBU, given point A.
-
ENTER Point A
ERROR: Point A
Is Point A MUST BE OUTSIDE
within CBU? CBU
DISPLAY
DISTANCE
END
- This is a derivative of a flow chart and its underlying factors are the correct extraction of
statements inside a flow chart symbol, listing them vertically and preservation of the
- For example; An equivalent Pseudo code to the flow chart above is:
EQUIVALENT PSEUDO CODE
BEGIN
ENTER Point A,
IF Point A is within CBU THEN
DISPLAY Error message,
ENTER Point A,
ELSE
Measure Distance between them,
ENDIF
DISPLAY Distance,
END.
We conclude this topic by solving a quadratic equation using a flow chart and a corresponding
pseudocode.
We also note that the equation ax2 +bx+c=0 can only be solved if the Discriminant, D=b 2-4*a*c>0(or
D>=0), that is D must not be negative (we are not dealing with complex numbers).so the above equation
will have no solutions if D<0. We also note that the inequality D<=0 will not hold and so cannot be used.
Example
Write a flow chart and a corresponding pseudo code to find the solution of the equation ax 2 +bx+c=0
Solution
a) Flow chart
b) Pseudocode
Start
Let D=b*b-4*a*c
If D<0 Then
If D>=0 Then
Print x1, x2
End .
FLOW CHARTS CONSTRUCTION
- A computer carries out all its tasks in a logical way.
- A set of logical steps that need to be followed in order to solve a problem are also
referred to as FLOW CHART.
How does one construct a flow chart?
- To construct a flow chart one needs to firstly master the symbols used and their meaning.
SYMBOL MEANING
BEGIN/END OR
START/ STOP
INPUT/OUTPUT OR ENTER
/DISPLAY
PROCESS
DECISION
PROGRAM FLOW
SYMBOL MEANING
ADDITIONAL
+
SUBTRACTION
‒
MULTIPLICATION
*
DIVISION
/