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