1.5 Algorithms
1.5 Algorithms
• Algorithm
• Flow Charts
• Pseudo Code
Program Planning
As flowcharts
As pseudocodes
Flowchart
Yes A=B
I=?
=0 =1 =2 =3 =4 =5 = Other
1. Sequence logic,
2. Selection logic, and
3. Iteration (or looping) logic
Process 1
Process 1
Process 2
Process 2
Yes No
IF (condition)
IF Condition THEN
THEN Process 1
Process 1 ENDIF
Yes
Type 1 Process 1
No
Yes
Type 2 Process 2 CASE Type
Yes
Type n Process n
Case Type n: Process n
No
ENDCASE
(a) Flowchart
(b) Pseudocode
Iteration (or Looping) Logic
Used to produce loops in program logic when one or more instructions may
be executed several times depending on some conditions
1. DO…WHILE
2. REPEAT…UNTIL
Iteration (or Looping) Logic
(DO…WHILE Structure)
False
Condition?
True
Process 1 DO WHILE Condition
Process 1
Block
Process n
Process n ENDDO
Process 1
REPEAT
Process 1
Process n
Process n
False
Condition? UNTIL Condition
True
(a) Flowchart (b) Pseudocode
Sample Algorithm (Example 1)
Step 8: Stop.
Flowchart Vs Pseudo code
Flowchart Pseudocode
Start/End Begin/End
Decision If/if-lse/case/while/
do-while/for
Connector Not Applicable
• Write a pseudo code and flowchart to find the factorial of the given
number
• Write a pseudo code and flowchart to find the given number is prime
or not?
• Write a pseudo code and flowchart to generate the Fibonacci series
upto n numbers.
• Write a pseudo code and flowchart to check the given number is
palindrome or not?