Module 2 Programing
Module 2 Programing
Programming.
Elements of programming.
✔ Syntax
✔ Variables
✔ Functions
✔ Arithmetic/Logic Operations
✔ Loop
Programming tools
Previously…
Programming tools
✔ Algorithm
▪ Characteristics
• Clarity and unambiguous
• Well defined input/output
• Finiteness
• Feasible
• Language independent
Previously…
Programming tools
✔ Algorithm
▪ Characteristics of Algorithm
▪ Advantages / disadvantages
▪ How to design an algorithm.
▪ Qualities of a good algorithm
✔ Pseudocode
✔ Flowchart – next discussion…
Flowchart
Is a graphical representation of an algorithm.
Symbols such as squares, diamonds, and ovals
represent various operations.
These symbols are connected by lines and arrows
to indicate the flow of data or control from one
point to another.
Flowchart Symbols
Terminal block
Decision block
Process block
Initialization block
Flow Lines
Terminal / Terminator Block
Ovals or rounded rectangles are used to
indicate the start and the end of a module
or program
START
An oval is labeled with the name of the
module at the start ; the end is indicated by
the word end or stop for the top or Control
Module END
A start has flow lines entering it and only
one exiting it; an end or exit has one flow
line entering it but none exiting it.
Process Block
The rectangle indicates a processing block, for
such things as calculations, opening and closing
files, and so forth.
A processing block has one entrance and one
exit. Sum=Num1+Num2
Input / Output Block Output
Input
The parallelogram indicates input to and
output operations
An I/O block has one entrance and only one
exit
Display
Get X
X
Decision Block
The diamond indicates a decision.
It has one entrance and exactly two exits from
the block. T Con F
ditio
One exit is the action when the resultant is n
TRUE and the other exit is the action when
resultant is FALSE. Action Action
when when
TRUE FALSE
Initialization Block
used for declaring / initializing variables
needed to solve a certain process.
Num
Declaration 1
❑ stating a variable name to be use Num
2
Num
Initialization 1=5
❑ to set (a starting value of a variable) Num
2=3
On-Page Connectors
The circle is used as a connection point
between two sections of a flowchart that are A
not adjacent or closely located to each other
3. Print age.
Is
variable
X< X
20? less than
20?
Conditional Statements
✔ Statements that result to TRUE or FALSE.
T F
✔ More on decision block.