Flowchart in Programming
Flowchart
- is a diagrammatic representation of an
algorithm
- can be helpful for both writing programs
and explaining the program to others
Review
Flow Line
Indicates the flow of logic by connecting symbols.
Terminal(Stop/Start)
Represents the start and the end of a flowchart.
Input/Output
Used for input and output operation.
Review
Processing
Used for arithmetic operations and data-manipulations.
Decision
Used for decision making between two or more alternatives.
Preparation
Used for preparing all the variables with their values as null.
Example No. 1:
Design a flowchart and make
an algorithm that will accept
2 numbers. Print the sum of
the inputted numbers.
Remember!
I - input
P - process
O - output
I - input
P - process
O - output
START
I - input –
START P - process
O - output
A = Null preparation
B = Null
C = Null
I - input – 2 (A & B)
START P - process
O - output
A = Null
B = Null
C = Null
input
Read
A&B
STAR I - input – 2 (A & B)
T P - process – A+B
O - output - C =A+B
A = Null
B = Null
C = Null
Read
A&B process
C=A+B
STAR
I - input – 2 (A & B)
T
P - process – A+B
A = Null O - output – C =A+B
B = Null
C = Null
Read
A&B
print
C=A+B
Print C
STAR
T
I - input – 2 (A & B)
A = Null P - process – A+B
B = Null
C = Null
O - output – C =A+B
Read
A&B
C=A+B print
Print C
END
Algorithm for Example No. 1
1. Initialize A, B, C, into null
2. Read the value of A & B
3. Find the value of C by the
formula: C =A+B
4. Print the value of C.
Example 2:
Design a flowchart and make
an algorithm that will accept
4 numbers (n1 to n4).
Compute & print the sum
and average.
STAR
T
I - input –
N1 =null
N2 =null
N3 =null
P - process –
N4 =null
Sum=null O - output –
Ave=null
Read
n1, n2, n3,
n4
Sum=n1+n2+n3+n4
Ave=Sum/4
Print
Sum, Ave
END
Algorithm for Example No. 2
1. Initialize n1, n2, n3, n4, sum, ave into null
2. Read the value of n1, n2, n3, n4
3. Find the value of Sum by the formula:
Sum=n1+n2+n3+n4
Find the value of Ave by the formula:
Ave=Sum/4
4. Print the value of Sum and Ave.
Practice/Activity:
Design a flowchart and make
an algorithm that will accept
hours. Convert & print the
value in minutes.
STAR
T
I - input –
P - process –
O - output –
END
Algorithm for Practice/Activity
1. Initialize n1, n2, n3, n4, sum, ave into null
2. Read the value of n1, n2, n3, n4
3. Find the value of Sum by the formula:
Sum=n1+n2+n3+n4
Find the value of Ave by the formula:
Ave=Sum/4
4. Print the value of Sum and Ave.
Performance Task - 1 Quarter
st
Rubric