Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

Algorithm & Flowchart

The document provides steps for program development including defining an algorithm and creating a flowchart. It explains that an algorithm is a step-by-step procedure to solve a problem and includes examples of algorithms to find the sum of two numbers, print "Hello World", and calculate the average of three marks. It also describes what a flowchart is and common flowchart symbols used to represent operations, flow, and data. Examples are given of a flowchart to find the sum of two numbers and to calculate the average of three marks. The document concludes by providing an algorithm and flowchart to read the length and breadth of a rectangle and calculate its area.

Uploaded by

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

Algorithm & Flowchart

The document provides steps for program development including defining an algorithm and creating a flowchart. It explains that an algorithm is a step-by-step procedure to solve a problem and includes examples of algorithms to find the sum of two numbers, print "Hello World", and calculate the average of three marks. It also describes what a flowchart is and common flowchart symbols used to represent operations, flow, and data. Examples are given of a flowchart to find the sum of two numbers and to calculate the average of three marks. The document concludes by providing an algorithm and flowchart to read the length and breadth of a rectangle and calculate its area.

Uploaded by

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

Steps for Program

Development
About
• A typical programming task can be divided into
two phases:
• Problem solving phase
▫ produce an ordered sequence of steps that describe
solution of problem
▫ this sequence of steps is called an algorithm
• Implementation phase
▫ implement the program in some programming
language
Algorithm

• Algorithm is a step by step procedure to solve


the given problem.
• In Algorithm each step is numbered in a
hierarchical order
• Number of steps must be finite
• Every step must be complete and error free
• Algorithms can’t be compiled or executed
Algorithm

• Example 1: Write an algorithm to find sum


of two numbers
Example: Algorithm to find sum of two numbers

Algorithm
ALGORITHM SUM_NUMBERS
//Purpose: To find sum of two numbers
//Input: Two numbers
//Output: Display sum

Step 1: [Input two numbers]


read a and b
Step 2: [find sum]
sum = a + b
Step 3: [Output the result]
print sum
Step 4: [Finish]
stop
Algorithm

• Every Algorithm should have a name


• Specify the purpose of an algorithm
• Also specify Input and Output for the algorithm
• Each step should have description enclosed
within a square bracket
• Every algorithm should end
Algorithm
Example 2: Write an algorithm to print Hello world

ALGORITHM TO PRINT MESSAGE


//Purpose: To print message

Step 1: start
Step 2: [ Print message]
print Hello world
Step 3 : [Finish]
stop
Algorithm

• Example 3: Write an algorithm to calculate


the average of three marks.
ALGORITHM
//Purpose: Calculate the average of three marks.
//Input: Marks of three subjects
//Output: Display Average

Step 1: [Input marks of three subjects]


read m1,m2,m3
Step 2: [find Average]
sum = m1+m2+m3
Avg=sum / 3
Step 3: [Output the result]
print Avg
Step 4: [Finish]
stop
Flowchart
• Flowchart is a graphical or pictorial
representation of the algorithm
Flowchart

• Pictures are more understandable than the text


• Predefined symbols are used for each step
• Symbols are used to represent sequence of
operations, flow of data and documents
required
• With flowchart it is easier to understand data
and control flow
Flowchart
Symbol Name Description

Used to connect symbols and


Arrow
also indicate flow of control

Used to indicate beginning


Oval
(Start) or end (End) of the task

Used for input or output


Parallelogram
operation

Used for arithmetic or data


Rectangle
manipulation operations

Used for any logic or


Diamond
comparison operations
Flowchart
Symbol Name Description

Used to join different flow


Connector
lines

Used to represent a group of


Predefined statement that perform one
processing task

Hexagon Used to repetitive statements


Flowchart

• Example 1: Write a flowchart to find sum


of two numbers
Flowchart
Example: Flowchart to find sum of two numbers

Start

Read a, b

sum = a + b

Print sum

Stop
Flowchart
• Example 2: Write a flowchart to print hello
world
Flowchart

• Example 3: Write a flowchart to calculate


the average of three marks.
Flowchart
Example:

• Write an algorithm and draw a flowchart


that will read the two sides of a rectangle
and calculate its area.
Algorithm

Algorithm AreaRect
//purpose: Start
//Input: length n breadth
//output: area

Step 1: [input sides of rect] Read l , b


read l,b
Step 2: [calculation]
area=l*b
Step 3: [display the result] Area=l*b
print area
Step 4: [finish]
stop

Print area

Stop

You might also like