Flow Chart and Algorithm
Flow Chart and Algorithm
The main purpose of using an algorithm is to illustrate the flow of data and problem solution logic.
An algorithm generally takes some input, carries out a number of effective steps in a finite amount of
time, and produces some output.
B. PSEUDOCODE
Kind of structured English for describing algorithms. It allows the designer to focus on the logic of the
algorithm without being distracted by details of language syntax. At the same time, the pseudocode
needs to be complete. It describes the entire logic of the algorithm so that implementation becomes a
rote mechanical task of translating line by line into source code
Pseudocode is a compact and informal high-level description of a program using the conventions of a
programming language, but intended more for humans.
There is no pseudocode standard syntax and so at times it becomes slightly confusing when writing
Pseudocode and so let us understand pseudo code with an example.
Example #1
Write a program to find the Perimeter and Area of a rectangle.
• -To find the area of a rectangle, you need to know the rectangle's length and width.
• The perimeter and area of the rectangle are then given by the following formulas:
– perimeter = 2 * (length + width)
– area = length * width
Pseudocode
1. Get the length
2. Get the Width
3. perimeter = 2 * (length + width)
4. area = length * width
5. Display the perimeter
6. Display the area
Example -#3:
Pseudo-code to read a number (assumed to be non-zero), check whether it is positive or negative and
output the result.
It is an aid to solve a complex problem easily and efficiently. It shows the detailed view of a program
flow.
1. Use common statements that are easy to understand for words within flowchart symbols.
2. Be consistent in using names and variables in the flowchart.
3. Go from left to right and top to bottom in constructing flowcharts.
4. Keep the flowchart as simple as possible.
5. If a new flow charting page is needed, break the flowchart at an input or output point. Use properly
labeled connectors to link the flowchart on different pages.
Algorithm Flowchart
An algorithm is a finite sequence of well-defined
steps or operations for solving a problem in a It is graphical representation of algorithm
systematic manner.
It is easy to write and difficult to understand than It is difficult to draw and easy to understand than
flowchart algorithm
It does not follow strict rules It use standard symbols for drawing.
Algorithm:
Flowchart
Example #2: Determine Whether A Student Passed the Exam or Not:
Algorithm:
Flowchart