Algorithm in Programming
In programming, algorithm is a set of well defined
instructions in sequence to solve the problem.
Qualities of a good algorithm
1) Input and output should be defined precisely.
2) Each steps in algorithm should be clear and
unambiguous.
3) Algorithm should be most effective among
many different ways to solve a problem.
4) An algorithm shouldn't have computer code.
Instead, the algorithm should be written in such
a way that, it can be used in similar
programming languages.
Write an algorithm to add two numbers
entered by user.
Step 1: Start
Step 2: Declare variables num1, num2 and
sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the
result to sum. sum←num1+num2
Step 5: Display sum
Step 6: Stop
An introduction to Flowcharts
What is a Flowchart?
Flowchart is a graphical representation of an
algorithm. Programmers often use it as a
program-planning tool to solve a problem. It
makes use of symbols which are connected
among them to indicate the flow of
information and processing.
The process of drawing a flowchart for an
algorithm is known as “flowcharting”.
Common Flowchart Symbols
Different flow chart symbols have different meanings. The
most common flow chart symbols are:
Terminator: An oval flow chart shape indicating the start or
end of the process.
Process: A rectangular flow chart shape indicating a normal
process flow step.
Decision: A diamond flow chart shape indication a branch in
the process flow.
Connector: A small, labeled, circular flow chart shape used
to indicate a jump in the process flow. (Shown as the circle
with the letter "A", below.)
Data: A parallelogram that indicates data input or output
(I/O) for a process.
Document: Used to indicate a document.
Addition of two numbers