Lesson 8 - Flowchart

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Lesson8:

Algorithms and
Flowchart
Outline:
1. Algorithms
2. Program Development Process
3. Flowchart
4. Symbols and Functions
5. Types of flowchart
6. Advantages and disadvantages
7. Sample Problem
Program Development Process
Problem Analysis

Program Design

Program Coding

Program Testing
and Debugging

Program
Documentation and
Maintenance
Algorithm
• Is a sequence of steps required to solve a problem.
• It is a list of well defined instructions to solve a
problem.

Example: Algorithm in preparing coffee


Start
Step 1: Prepare a cup of warm water
Step 2: Put coffee powder
Step 3: Add a little amount of sugar
Step 4: Stir or mix it
Stop
Examples:
1. Make an algorithm to input two numbers and print
the sum.
Start
Step 1: Input two numbers and place it in a variable name “num1” and “num2”

Step 2: Add value of num 1 and value of num2,


then assign the result to the variable named “sum” or you may use the formula
sum = num1 + num2

Step 3: display the sum


Stop
Try this one!
2. Create an algorithm that will find the
greatest value between two numbers
Start
Step 1: Declare two variable name A and B
Step 2: Input value of A and B
Step 3: if A > B
Print “A is greater than B”
Else
Print “B is greater than A”
Stop
Flowchart
- Flow charts are used in analysing ,designing,
documenting or managing a process or
programin various fields.
- It is a type of diagram that represents an
algorithm, workflow or process, showing the
steps as boxes of various kinds, and their order
by connecting them with arrows.
- Flow chart are used in designing and
documenting complex processes or programs.
Flowchart
Symbols
Start / end
Represented as oval or rounded
rectangles, usually containing the
word “Start” or “End” , or
another phrase signalling the start
or end of a process , such as
“submit inquiry” or “receive
product”.
- Showing “flow ofcontrol”.
- An arrow coming from one
symbol and ending at another
symbol represents that control
passes to the symbol the arrow
points to .
- Represented as rectangles.
- Use it to represent an event process
which is controlled within the
process.
- Typically this will be a step or
action which is taken.
- In most flowcharts this will be
the most frequently used
symbol.
- Examples: “Add 1 to X”; “replace
identified part”; “save changes”
or similar.
- Represented as a parallelogram.
- Represents material or
information entering or leaving
Input/output
the system, such as customer
order (input) or a product
(output).
- Example: Get X from the user;
display X.
- A decision or branching
point. Lines representing
different decisions emerge
from different points of
the diamond. decision
- Only one flow line should
enter a decision symbol but
two or three lines may
leave it depending on the
options that can be chosen
- this symbol is typically small
and is used as a Connector to
show a jump from one point in A
the process flow to another.
- Connectors are usually labeled
with capital letters to show A

matching jump points.


- They are handy for avoiding
flow lines that cross other
shapes and flow lines.
- shows continuation of a
process flowchart onto
another page. A-1
- When using them in
conjunction with
Connectors, it's best to
differentiate the labels,
e.g. use numbers for Off-
Page Connectors and capital
letters for Connectors.
Types of
Flowchart
1. Program flowchart
2. System flowchart
Shows the sequence of instructions in a program or
subroutine. These instructions are followed the
procedure needed

I N PU T

PROCESS

O U T PUT

DECI SI O N

EN D
Types of flowchart

 Program flowchart is a diagrammatic


representation of a solution to a given
problem for which the program is written.
(see Figure 1.1)
 System flowchart is a diagrammatic
representation of the broad flow of work,
document and operations. (see Figure 1.2)
Start

Input
Name,HrlyRate,
HrsWork,
Deduction
Problem 1:
GrossPay = Hrly * HrsWork

Get the following data from the


user: employee’s name, hourly NetPay = GrossPay - Deduction

rate, number of hours worked, and Print


deductions, calculate and display Name, GrossPay,
the employee’s gross pay and net NetPay

pay.
End

Figure 1.1
Figure 1.2
Advantages of Flow Charts
A good way to communicate the details of a task or
processes to others
An excellent way of documenting each stage of the
process
Acts a blue print guiding the programmer through
the development
Disadvantages of Flow Charts
Some tasks are difficult to represent using a flow
chart
If and alteration is made then the flow chart may
need to be redrawn
People need to understand what the symbols mean
Programs – a list of organized instructions that the computer must follow
in order to process data into information.
Programming – art and science of creating programs, also called as
software engineering.
Coding – the actual writing of the program.
Algorithm – a set of ordered steps for solving a problem an essentially a
synonym of logic.
Syntax – consists of the rules governing the structure and content of the
statements.
Data – information processed or stored by a computer. This information
may be in characters, integers, decimal or float etc.
Variables – names used to refer to some location in Memory – a location
that holds a value with which we are working.
The End!

You might also like