FLOWCHART and ALGORITHM
FLOWCHART and ALGORITHM
AND
ALGORITHMS
The word “algorithm” relates to the name of the mathematician Al-khowarizmi, which means a procedure or a
technique. Software Engineer commonly uses an algorithm for planning and solving the problems. An algorithm is a
sequence of steps to solve a particular problem or algorithm is an ordered set of unambiguous steps that produces a
result and terminates in a finite time Algorithm has the following characteristics
– Input: An algorithm may or may not require input
– Output: Each algorithm is expected to produce at least one result
– Definiteness: Each instruction must be clear and unambiguous.
– Finiteness: If the instructions of an algorithm are executed, the algorithm should terminate after finite number of
steps
The algorithm and flowchart include following three types of control structures.
1. Sequence: In the sequence structure, statements are placed one after the other and the execution takes place
starting from up to down.
2. Branching (Selection): In branch control, there is a condition and according to a condition, a decision of either
TRUE or FALSE is achieved. In the case of TRUE, one of the two branches is explored; but in the case of FALSE
condition, the other alternative is taken. Generally, the ‘IF-THEN’ is used to represent branch control.
3. Loop (Repetition): The Loop or Repetition allows a statement(s) to be executed repeatedly based on certain
loop condition e.g. WHILE, FOR loops.
Advantages of algorithm
– The first design of flowchart goes back to 1945 which was designed by John Von
Neumann. Unlike an algorithm, Flowchart uses different symbols to design a solution to a
problem. It is another commonly used programming tool. By looking at a Flowchart ,one
can understand the operations and sequence of operations performed in a system.
Flowchart is often considered as a blueprint of a design used for solving a specific
problem.
– Flowchart is a diagrammatic representation of an algorithm. Flowchart are very helpful
in writing program and explaining program to others.
– Though, flowchart are useful in efficient coding, debugging and analysis of a program,
drawing flowchart in very complicated in case of complex programs and often ignored.
– Flowcharts use special shapes to represent different types of actions or steps in a
process. Lines and arrows show the sequence of the steps, and the relationships among
them. These are known as flowchart symbols. So Flowchart symbols are specific shapes
used to create a visual representation of a program.
Advantages of flowchart:
– Rectangle Shape -
Represents a
process
– Oval or Pill Shape -
Represents the start
or end
– Diamond Shape -
Represents a
decision
– Parallelogram -
Represents
input/output
Functions of Flowchart Symbols
– Each symbol has its own function within the program. Each symbol
represents a piece of the code written for the program. The start/end symbol
can be used to represent either the beginning or ending of a program. The
symbol for process allows you to show how the program is functioning, like
when you need the program to calculate two numbers or even analyze the
information.
– When you decide to enter data, show it on the screen, or print it to paper,
you use the input/output symbol. The display symbol signifies that
information is displayed to the user.
– There are many other symbols frequently used in flowcharts.
The decision symbol is used for things like 'if statements,' where you must
choose an option based on a specified criteria. A decision question may be
something as simple as: if the grade is at least 70 then send out the message
'Passing' to the screen. Otherwise, send 'Failing' to the screen.
Comparison between Algorithm and
Flowchart
Algorithm Flowchart
– It is a procedure for solving problems. – It is a graphic representation of a
process.
– The process is shown in step-by-step
instruction. – The process is shown in block-by-block
information diagram.
– It is complex and difficult to understand.
– It is intuitive and easy to understand.
– It is convenient to debug errors
– It is hard to debug errors.
– The solution is showcased in natural
language. – The solution is showcased in pictorial
format.
– It is somewhat easier to solve complex
problem. – It is hard to solve complex problem.
– It costs more time to create an algorithm. – It costs less time to create a flowchart.
Some examples
Draw a flowchart along with its
algorithm to add two numbers
entered by user.
AN ALGORITHM TO FIND THE SUM
OF TWO NUMBERS:
– STEP 1 : START
– STEP 2 : DECLARE VARIABLES
– STEP 3 : READ NUMBERS
– STEP 4 : SUM THESE TWO
NUMBERS
– STEP 5 : DISPLAY SUM
– STEP 6 : STOP
Draw a flowchart along with its
algorithm to do difference among
two numbers entered by user.
AN ALGORITHM TO FIND THE
DIFFERENCE IN BETWEEN TWO
NUMBERS:
– STEP 1 : START
– STEP 2 : DECLARE VARIABLES
– STEP 3 : PERFORM DIFFERENCE IN
BETWEEN THESE TWO NUMBERS
– STEP 5 : DISPLAY ANSWER
– STEP 6 : END
Draw a flowchart along with its
algorithm to convert temperature
(Celsius to Fahrenheit)
– Step 1: Start
– Step 2: Read the
temperature value in
Celsius
– Step 3: Applying
Formula of
Conversion i.e,
F=(9*C)/5+32
– Step 4: Print the
Temperature in
Fahrenheit
– Step 5: Stop
Draw a flowchart along with its
algorithm to convert temperature
(Fahrenheit to Celsius)
– Step 1: Start
– Step 2: Read the
temperature value in
Fahrenheit
– Step 3: Applying
Formula of
Conversion i.e,
C=(5*(F-32))/9
– Step 4: Print the
Temperature in
Celsius
– Step 5: Stop
Some more examples (flowchart for
checking given number is odd or even)
try writing the algorithm by yourself
Some more examples (flowchart
for printing numbers 1 to 20)
Some more examples (flowchart for
finding average of two numbers)
try writing the algorithm by yourself
Some more examples (flowchart for
finding greater number of among given
two numbers) try writing the algorithm
by yourself
REFERENCES:
– http://www.yspuniversity.ac.in/cic/algorithm-manual.pdf
– http://programmingposts.com/c-program-converting-celsius-fahrenheit/
– https://www.edrawsoft.com/explain-algorithm-flowchart.html
– https://www.c-programming-simple-steps.com/flow-chart.html
– https://faradars.org/wp-content/uploads/2015/07/Algorithm-and-Flow-
Chart.pdf