DS02 Flow Chart and Pseudo Code by Jyoti Lakhani
DS02 Flow Chart and Pseudo Code by Jyoti Lakhani
DS02 Flow Chart and Pseudo Code by Jyoti Lakhani
Flowchart Symbols
Data File or
Database
Single documents
Multiple documents
© Dr. Jyoti Lakhani
Manual operation
Manual input
Preparation or Initialization
http://flowgorithm.org/download/index.htm
General English
Start
Input n1
Input n2
Sum = n1 + n2
Print Sum
End
Start
1. sum <- n1 + n2
2. Print sum
End
It has no syntax like any of the programming language and thus can’t
be compiled or interpreted by the computer.
3. Arrange the sequence of tasks and write the pseudo code accordingly
Example:
This program will allow the user to check the number whether it's
even or odd. © Dr. Jyoti Lakhani
5. Proper Indentation:
The way the if-else, for, while loops are indented in a program, indent the
statements likewise, as it helps to comprehend the decision control and
execution mechanism. They also improve the readability to a great extent.
Example:
if "1“ print response "I am case 1“ if "2“ print response
"I am case 2"
Example:
if "1"
print response "I am case 1"
if "2"
print response "I am case 2".
© Dr. Jyoti Lakhani
5. Don’t be labor the obvious:
In many cases, the type of a variable is clear from context; it is often
unnecessary to make it explicit.
11. Check whether all the sections of a pseudo code is complete, finite and clear to
understand and comprehend
4. The main goal of a pseudo code is to explain what exactly each line
of a program should do, hence making the code construction
phase easier for the programmer
Pseudo code resembles skeleton programs which can be compiled without errors.
Flowcharts,
drakon-charts and
Unified Modelling Language (UML) charts can be thought of as a graphical
alternative to pseudo code, but are more spacious on paper.
Languages such as HAGGIS bridge the gap between pseudo code and code written in
programming languages.
- Wiki
Type of
Symbol Example
operation
Assignment ← or := c ← 2πr, c := 2πr
Comparison =, ≠, <, >, ≤, ≥
Arithmetic +, −, ×, /, mod
Floor/ceiling ⌊, ⌋, ⌈, ⌉ a ← ⌊b⌋ + ⌈c⌉
Logical and, or
Sums, products ΣΠ h ← Σa∈A 1/a
- Wiki
© Dr. Jyoti Lakhani
Action Words
Input: READ
OBTAIN
GET
Output:
PRINT
DISPLAY
SHOW
Compute:
COMPUTE
CALCULATE
DETERMINE
Initialize:
SET
INIT
Add one:
INCREMENT
BUMP
© Dr. Jyoti Lakhani
IF-THEN-ELSE
The general form is:
IF condition THEN
sequence 1
ELSE
sequence 2
ENDIF
Example:
WHILE condition
sequence
ENDWHILE
Example:
REPEAT
sequence
UNTIL condition
NESTED CONSTRUCTS
Example:
SET total to zero
REPEAT
READ Temperature
IF Temperature > Freezing THEN
INCREMENT total
END IF
UNTIL Temperature < zero
© Dr. Jyoti Lakhani
INVOKING SUBPROCEDURES
Use the CALL keyword.
For example:
EXCEPTION HANDLING
BEGIN
statements
EXCEPTION
WHEN exception type
statements to handle exception
WHEN another exception type
statements to handle exception
END