Anda di halaman 1dari 19

CS001P

Flowchart
A pictorial representation of the logical
steps it takes to solve a problem.
A flowchart is a diagrammatic
representation that illustrates the
sequence of operations to be performed
to get the solution of a problem.

Guidelines in Drawing Flowcharts


In drawing a proper flowchart, all necessary
requirements should be listed out in logical order.
The flowchart should be clear, neat and easy to follow.
There should not be any room for ambiguity in
understanding the flowchart.
The usual direction of the flow of a procedure or
system is from left to right or top to bottom.
Only one flow line should come out from a process
symbol.

Only one flow line should enter a decision symbol, but


two flow lines, one for each possible answer, should
leave the decision symbol.
Only one flow line is used in conjunction with terminal
symbol.
If the flowchart becomes complex, it is better to use
connector symbols to reduce the number of flow lines.
Avoid the intersection of flow lines if you want to make
it more effective and better way of communication.
Ensure that the flowchart has a logical start and finish.
It is useful to test the validity of the flowchart by
passing through it with a simple test data.

Flowchart Symbols
Flowcharts are usually drawn using some
standard symbols; however, some special
symbols can also be developed when
required. Some standard symbols, which are
frequently, required for flowcharting many
computer programs are the following:

Terminal Symbol - shows the start and stop


points in a process.
Preparation Symbol - as the names states,
any process step that is a preparation process
flow step, such as a set-up operation.

Input/output Symbol - indicates inputs to and


outputs from a process.

Process Symbol - shows a process or action step. This is the


most common symbol in both process flowcharts and
business process maps.

Predefined Process (Subroutine) Symbol - is a marker for


another process step or series of process flow steps that
are formally defined elsewhere. This shape commonly
depicts sub-processes (or subroutines in programming
flowcharts). If the sub-process is considered "known" but
not actually defined in a process procedure, work
instruction, or some other process flowchart or
documentation, then it is best not to use this symbol since
it implies a formally defined process.

Decision Symbol - Indicates a question or branch


in the process flow. Typically, a
decision flowchart shape is used when there are
2 options (Yes/No, No/No-Go, etc.)

On-Page Connector Symbol - to show a jump


from one point in the process flow to another.

Flow lines a flow of control arrows indicating


the sequence of steps.

Entries and Exits


The following will show you the number of
entries and exits from each symbol.
1 entry

1 exit

1 entry, 2 exits
1 entry, 1 exit

1 entry, 1exit

Programming Control Structures

Sequence
Selection / Decision
Iteration / Loop

Sequential Control Structure


A sequence execution of processes. Each
instruction is executed in a serial manner, one
after another.

Process 1

Process 2
Process 3
11

Sequential Control Structure


PROBLEM : (Application of Sequential
control structure) Draw a flowchart that will
compute for the sum of two numbers.

Start

Num1=0;
Num2=0,
answer =0;

PSEUDOCODE:
S1: GET num1
S2: GET num2
S3: answer = num1 + num2
S4: DISPLAY answer

Input num1, num2

answer =num1 + num2

Display answer

Stop
12

Decision/Selection Control Structure


Provide a decision point that allows one of two
choices to be chosen.
Process 1
YES

NO

CONDITION

Option 1

Option 2
NO

YES

EOF?

Stop
13

Condition must always yield a


Yes or No / True or False

Logical Operators: NOT, AND, OR

Decision/Selection
Control Structure

Start

PROBLEM: (Application of decision control


structure). Draw a flowchart that will determine
the smallest between two numbers.

Num1 = 0;
Num2 = 0;
ans=0;

Input Num1,
Num2

PSEUDOCODE:
GET a value for Num1, Num2
IF Num1 < Num2
THEN print the value of Num1
ELSE print the value of Num2
END IF

YES

NO
Num1<Num2

Display Num1

Display Num2

Stop
15

Selection / Decision Control Structure


PSEUDOCODE:
DISPLAY main menu
GET choice
DOCASE
choice 1
DISPLAY ("Choice 1 selected")
choice 2
DISPLAY ("Choice 2 selected")
choice 3
DISPLAY ("Choice 3 selected")
choice 4
DISPLAY ("Choice 4 selected")
ENDCASE

16

Answer:

Start
Display Main
Menu
Input choice
YES

Choice=1

Display
Choice 1
selected"

NO
YES

Choice=2
NO

YES

Display
Choice 3
selected"

YES

Display
Choice 4
selected"

Choice=3
NO

Choice=4

Display
Choice 2
selected"

NO

Stop
17

Assignment
Accepts letter grade and display
corresponding remark based on the following:
Letter Grade
A
B
C
D

Remark
Excellent work!
You did well...
Average performance
Needs some improvement...
Trouble ahead

Assignment
Accepts numeric grade and display equivalent
letter grade based on the following:
Numeric Grade
90-100
80-89
70-79
60-69
below 60

Letter Grade
A
B
C
D
E