IntroductionToProgramming L02
IntroductionToProgramming L02
Flowchart
Asst. Prof. Dr. Yalçın İşler
Izmir Katip Celebi University
What is flowchart
A diagram that uses graphic symbols to depict the
nature and flow of the steps in a process.
• Prepare conditional: Represented as a hexagon. Shows operations which have no effect other than
preparing a value for a subsequent conditional or decision step (see below).
• Junction symbol: Generally represented with a black blob, showing where multiple control flows
converge in a single exit flow. A junction symbol will have more than one arrow coming into it, but
only one going out. In simple cases, one may simply have an arrow point to another arrow instead.
These are useful to represent an iterative process (what in Computer Science is called a loop). A
loop may, for example, consist of a connector where control first enters, processing steps, a
conditional with one arrow exiting the loop, and one going back to the connector. For additional
clarity, wherever two lines accidentally cross in the drawing, one of them may be drawn with a
small semicircle over the other, showing that no junction is intended.
Flowchart Template, 1969@IBM
Start
Example:
Calculating the Triangle’s height, h
area of a Area = h * w / 2
triangle
Triangle’s area is = Area
Finish
Start
Example:
Calculating the Numbers, n1, n2, n3
average of 3
Avg = (n1+n2+n3) / 3
numbers given
from the The average is = Avg
keyboard
Finish
Start
Example:
Calculating the Mid-term exam score, m
overall score
from given Final exam score, f
scores
Finish
Example: Finding
the greater number Start
between 2 numbers
given using Numbers, x, y
keyboard
x>y?
YES, 1
NO, 0
Finish
Example: Finding the Start
x>z? y>z?
NO, 0
NO, 0
YES, 1 YES, 1
M=x M=z M=y
Maximum is = M
Finish
Example: Finding whether the
Start
number given from the
keyboard is even or not Number, x
x mod 2 = 0 ?
YES, 1
NO, 0
EVEN ODD
Finish
Start
Example: Total = 0
sum of all
numbers Total = Total + Number
between 1 and
100 Total is = Total
Finish
Start
Example: T=0
Calculating x=10,1,100
numbers T=T+x
between 10
and 100
Total of even
numbers is = T
Finish
Start
Example: T=0
Calculating x=10,2,100
the sum of
only even
numbers T=T+x
between 10
and 100
Total of even
numbers is = T
Finish
Homework #2
Not later than the next week:
1. Draw a flowchart that displays the type of triangle when the
border lengths are given using the keyboard.
2. Draw a flowchart that finds and displays the average of even
numbers and odd numbers separately between 10 and 250.
3. Draw a flowchart that finds and displays how many numbers
can be divided by 5 without remaining.
4. Draw a flowchart that finds and displays the average of non-
negative numbers (>=0) between the lower and upper limits
given from the keyboard.
5. Draw a flowchart that finds and displays the number of
negative numbers given from the keyboard until the value of 0
given.