Go, change the world
RV College of
Engineering
UNIT-I
Algorithm and
Flowchart
RV College of
Engineering Algorithm Go, change the world
Definition
In programming, algorithm is a set of well defined instructions in sequence to solve the
problem.
Qualities of a good algorithm
□Input and output should be defined precisely.
□Each steps in algorithm should be clear and unambiguous.
□Algorithm should be most effective among many different ways to solve a problem.
□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.
RV College of
Engineering Algorithm Go, change the world
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
RV College of
Engineering Algorithm Go, change the world
Write an algorithm to find the largest among three different numbers entered by user.
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
RV College of
Engineering Advantages of Go, change the world
□ It is a step-wise representationAlgorithm
of a solution to a given problem, which makes it easy to understand.
□An algorithm uses a definite procedure.
□It is not dependent on any programming language, so it is easy to understand for anyone even
without programming knowledge.
□Every step in an algorithm has its own logical sequence so it is easy to debug.
□By using algorithm, the problem is broken down into smaller pieces or steps hence, it is easier
for programmer to convert it into an actual program
RV College of
Engineering Disadvantages ofAlgorithm Go, change the world
□ Writing algorithm takes a long time.
□An Algorithm is not a computer program, it is rather a concept of how a program should be.
RV College of
Engineering Flowchart Go, change the world
A flowchart is a type of diagram that represents an algorithm, workflow or process.
The flowchart shows the steps as boxes of various kinds, and their order by connecting the
boxes with arrows. …
Flowcharts are used in analyzing, designing, documenting or managing a process or program
in various fields.
RV College of
Engineering Flowchart Go, change the world
RV College of
Engineering Advantages of Go, change the world
Flowchart
□The Flowchart is an excellent way of communicating the logic of a program.
□It is easy and efficient to analyze problem using flowchart.
□During program development cycle, the flowchart plays the role of a guide or a blueprint.
Which makes program development process easier.
□After successful development of a program, it needs continuous timely maintenance during
the course of its operation. The flowchart makes program or system maintenance easier.
□It helps the programmer to write the program code.
□It is easy to convert the flowchart into any programming language code as it does not use
any specific programming language concept.
RV College of
Engineering Disadvantages ofFlowchart Go, change the world
□The flowchart can be complex when the logic of a program is quite complicated.
□Drawing flowchart is a time-consuming task.
□Difficult to alter the flowchart. Sometimes, the designer needs to redraw the complete flowchart to
change the logic of the flowchart or to alter the flowchart.
□Since it uses special sets of symbols for every action, it is quitea tedious task to develop a
flowchart as it requires special tools to draw the necessary symbols.
□In the case of a complex flowchart, other programmers might have a difficult time understanding
the logic and process of the flowchart.
□It is just a visualization of a program, it cannot function like an actual program
RV College of
Engineering Example Go, change the world
RV College of
Engineering Example Go, change the world
RV College of
Engineering Example Go, change the world
RV College of
Engineering Example Go, change the world
RV College of
Engineering Example Go, change the world
RV College of
Engineering Example Go, change the world
RV College of
Engineering Example Go, change the world