0% found this document useful (0 votes)
7 views

2.algorithm & Flowchart

Uploaded by

shewaledipa2210
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

2.algorithm & Flowchart

Uploaded by

shewaledipa2210
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

ALGORITHM

AND
FLOWCHART
 ALGORITHM

 An algorithm is "rules or procedures" for solving problems


and are used in all aspects of daily life activities. Two
important aspects of algorithms are that the problem
should be expressed in detail and without ambiguity. To
solve any problem, it is important to follow the stepwise
strategy.
 A pseudocode (false code) is a language similar to English
but resembles computer programming code too. For
example, Read A.
 USES OF ALGORITHM
 Algorithm play a key role in developing computer programs.
 It can be effectively used to perform mathematical
calculations to get the desired result.

 Characteristics of a good algorithm include Input, Output,


Definiteness, Effectiveness and Termination.
 Steps to develop an algorithm:

 To develop an algorithm, a user goes through a number of


steps such as Analysis, Begin, Input, Processing and Output.
 Rules for writing an algorithm:
 Always begin the first step with START
 Always write each step in a separate line and number them.

 Use the word INPUT or READ when you want an INPUT.

 Use the word PRINT or WRITE when you want an OUTPUT.

 Always end with STOP.

 Do not make the algorithm too long


 HOW TO WRITE AN ALGORITHM
 An example of how to write an algorithm is given below :-
 Write an algorithm to find the Simple Interest (SI) by inputting the
values of Principal(P), Rate(R) and Time(T)
 Step 1: START
 Step 2: INPUT P, R, T

 Step 3: Calculate the Simple Interest, SI = (P*R*T) / 100

 Step 4: PRINT SI

 Step 5: STOP
 FLOWCHART
A flowchart is a diagrammatic representation of an algorithm, in which
different steps are shown as symbols of different shapes connected by
arrows. The arrows are responsible for the direction of flow of program.
Different shapes used in a flowchart and their functions are listed below:
Use of flowchart

.Flowchart helps to understand the stepwise working of a process easily.


. It is used in engineering, computer programming, entertainment,
education and physical sciences for performing various tasks.
 Steps to design of flowchart
 Step 1: Understand the process for which the flowchart is to be drawn.
 Step 2: List the steps of the process (algorithm)
 Step 3: Begin with START symbol.
 Step 4: Write the first step in appropriate symbol .
 Step 5: Write each successive step in its respective symbol .
 Step 6: Add arrows between symbols to show the flow of control.
 Step 7: Make sure all the flow paths reach the single STOP box.
 Rules for designing a flowchart

 A flowchart has only one START box and one STOP box.
 The direction of flow in a flowchart is either from top to bottom or
from left to right
 The flow of control follows only one path.
An example of how to draw a flowchart is given
below :-
 Draw a flowchart to find the average of three numbers.
 DECISION MAKING
 A computer uses the IF... ELSE statement for decision-making.
 When the condition after IF is true, the computer follows the
instructions after THEN.
 When the condition after IF is false, the computer evaluates
instruction after ELSE and then proceed further. This process is also
known as conditional problem solving.
 Note:
 In algorithms, the IF... THEN... ELSE statement is used whereas in
flowcharts, IS... YES... NO is used through a decision box.
 Below is an example of decision making with
algorithm and flowchart

Que. Write an algorithm and draw a flowchart to enter temperature in


Fahrenheit, convert it into Celsius and print whether the body temperature is
normal or not.
 Step 1: START
 Step 2: Read temperature in Fahrenheit, F
 Step 3: Calculate temperature in Celsius as C = 5/9 * (F – 32)
 Step 4: IF (C = 37)
THEN
 PRINT Body temperature is normal
 Step 5: STOP
 FLOWCHART

You might also like