You are on page 1of 12

IT108 Data Structures

Instructor: Ms. Rosalie P. Alejandro

Program Flowchart

Design tool commonly used in designing input, output and process flow of a program

A graphical representation of the program logic using standard symbols


Using three primary program constructs; sequence, selection and iteration/repetition

Three Program Constructs in Flowchart

Sequence
A sequential execution of process. Each instruction is executed in a serial manner, one after another

Selection
Provide a decision point that allows one of two choices to be chosen

Iteration
Repeat a set of instructions a number of times based on condition stated. This loop will end when condition has been fulfilled

Symbols Used in Program Flow Chart


Processing Program flow Decision Terminal Connector Input/Output

Sequence Example:
Start

Get number1

Get number2

answer = number1 / number2

Display answer

Stop

Selection Example 1
Start Get number1

Get number2

yes

number2= 0?

Display "Division by zero error"

answer = number1 / number2

Display answer

Stop

Selection Example 2
Start Display main menu

Get choice

yes choice =1? no yes

Display "choice 1 selected"

choice =2?
no yes choice =3? no yes choice =4? no Stop

Display "choice 2 selected"

Display "choice 3 selected"

Display "choice 4 selected"

Iteration Example 1
Start

total = 0

Get number

no number < 1000? yes total = total + number2

Display total

Stop

Iteration Example 2
Start

i=1

no i <= 12? yes result = i * 9 Stop

Display (i, "*9=",result)

i=i+1

Connector Example

A program to accept input of a series of numbers and total up value entered until 0 is entered. Then display number of data entered and total
Start Enter Number Yes Number = 0? Display N, Total Stop

No Total = Total + Number

N = N + A

Exercises

Draw a flowchart for a program which will output the total of a list of non-negative numbers input from the keyboard. The list of numbers is terminated with any negative number.

End of Slide

You might also like