Professional Documents
Culture Documents
Lecture 05
Lecture 05
Lecture 5
Introduction to Computing
bilal mir
Algorithm
Step by step procedure to solve a problem.
Step by step set of instructions for solving an
input (problem) to generate an output.
A precise statement to solve problems using
computer.
Two ways to design an algorithm:
Pseudo Code
Combination of natural languages and programming
languages.
More reliable than flow chart.
Flow chart
02/27/23
Introduction to Computing bilal mir
Properties of Algorithm
Simple
Efficient
Retain less memory
Not too much time consuming
Accurate
Complete
Finite
Introduction to Computingbilal
Denotes mir
the direction of logic flow in the program
Flow line
Example
START
Step 1: Input M1,M2,M3,M4
Input
Step 2: GRADE (M1+M2+M3+M4)/4
M1,M2,M3,M4 Step 3: if (GRADE <50) then
Print “FAIL”
GRADE(M1+M2+M3+M4)/4 else
Print “PASS”
Step 4: end
N Y
IS
GRADE<50
PRINT PRINT
“PASS” “FAIL”
STOP
Lcm Lft x 30
Print
Lcm
STOP
Algorithm START
Step 3: Print A
ALxW
Print
A
STOP
Y is
N
A>B
Print A Print B
If A>B then
print A Y is
N
A>B
else
print B
Print A Print B
end
Operator Description
> Greater than
= Equal to
Not equal to