Problem Solving: Algorithms and Flowcharts
Problem Solving: Algorithms and Flowcharts
English description
More easily More
expressed Pseudo-code precise
High-level
programming language
PSEUDOCODE & ALGORITHM
• SEQUENTIAL LOGIC
STRUCTURE
• Sequential logic structure – we
ask the computer to process a set
of instructions in sequence from
the top to bottom of an algorithm
OR
• a sequence followed without
skipping any line
PSEUDOCODE & ALGORITHM
Example 1: Write a sequential algorithm to prepare a
cup of tea.
PSEUDOCODE & ALGORITHM
Write algorithm for given problem:
You have a bottle of Pepsi and 7up. You have to swap the
liquid of bottle (i.e. in bottle of 7up you will have Pepsi and
in bottle of Pepsi you will have 7up).
PSEUDOCODE & ALGORITHM
Example 3: Write an algorithm to convert the
length in feet to centimeter.
Algorithm:
Input the length in feet (Lft)
Calculate the length in cm (Lcm) by multiplying LFT
with 30
Print length in cm (LCM)
EXAMPLE 3
Pseudocode
Step 1: Start
Step 2: Input Lft
Step 3: Lcm = Lft x 30
Step 4: Print Lcm
Step 5: End
PSEUDOCODE & ALGORITHM
Write an pseudo code that displays five number with their
squares
PSEUDOCODE & ALGORITHM
Quadratic equation= ax2+bx+c=0
PSEUDOCODE & ALGORITHM
Write an pseudo code that input value of a, b and c from
the user and compute the value of x by using quadratic
equation.
DECISION STRUCTURES
Y Is N
condition
true
Process 1 Process 2
Decision Structure: Pseudocode
IF–THEN–ELSE STRUCTURE
The structure is as follows:
If A>B then
print A
else
Y N
print B is
A>B
endif
Print Print
Print
AA PrintBB
PSEUDOCODE & ALGORITHM
Read a number from user and check if it is even or not
PSEUDOCODE & ALGORITHM
Find smallest of 3 numbers