Algorithm and Flowchart
Algorithm and Flowchart
Pratik Shah
II-CSE (Div B)
24/01/23 – 12/05/23
Algorithm
• Algorithm is a step – by – step procedure which is helpful in solving a
problem.
• If, it is written in English like sentences then, it is called as ‘PSEUDO
CODE’.
• An algorithm is a finite set of instructions, if followed and
accomplishes a particular task.
• It is a sequence of computational steps that transform the input into a
valuable or required output.
Properties of an Algorithm
• An algorithm must possess the following five properties −
• Input
• Output
• Finiteness
• Definiteness
• Effectiveness
1. Input: An algorithm should have some inputs.
2. Output: At least one output should be returned by the algorithm after the completion of the
specific task based on the given inputs.
while(1<2)
{
number=number/2;
}
5. Effectiveness: Writing an algorithm is a priori process of actual implementation of the
algorithm.
So, a person should analyze the algorithm in a finite amount of time with a pen and paper to
judge the performance for giving the final version of the algorithm.
Algorithm 1: Add two numbers entered by the
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
Algorithm 2: Find the largest number among
three numbers
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
FLOW CHART
• Diagrammatic representation of an algorithm is called flow chart.
• A flowchart can be helpful for both writing programs and explaining
the program to others.
Symbols Used In Flowchart
Examples of flowcharts in programming
1. Add two numbers entered by the user.
2. Find the largest among three different
numbers entered by the user.
Difference Between Algorithm & Flowchart
Algorithm Flowchart
• It is defined as a sequence of well- • It is a graphical representation of an
defined steps. algorithm.
• These steps provide a solution/ a way • Programmers use it as a program-planning
to solve a problem in hand. tool in order to solve a problem.
• It gives the solution to a specific • This will help indicate the flow of control
problem. and information, and processing.
• This solution would be translated to • The process of drawing a flowchart for an
machine code, which is then executed algorithm is known as "flowcharting".
by the system to give the relevant • It is easy to understand.
output.
• It is difficult to understand. • It is difficult to debug.
• It is easy to debug.
Programming Language
• A programming language is a vocabulary and set of grammatical rules
for instructing a computer or computing device to perform specific
tasks.
• The term programming language usually refers to high-level
languages, such as BASIC, C, C++, COBOL, Java, FORTRAN, Ada,
and Pascal.
• Each programming language has a unique set of keywords (words that
it understands) and a special syntax for organizing
program instructions.
22-12-2017
Thank you !!
22-12-2017