F LO W C H A R
T
A flowchart A graphical representation
operations
of the insequence
an information
of system or program.
Information system flowcharts show how data flows from
source documents through the computer to final
distribution to users. Program flowcharts show the
sequence of instructions in a single program or subroutine.
Different symbols are used to draw each type of flowchart.
The flowchart…
shows logic of an algorithm
emphasizes individual steps and their interconnections
e.g. control flow from one action to the next
B A S IC S Y M B O L OF A F LO W C H A RT
.
Symbol Name Function
Terminal (Start/ It indicate the beginning or end of the
End) program
It indicates the direction of logic flow in
Flow Lines
the program
Input / Output (IO) It indicate an input or output operation
It indicate a process such as a
Process mathematical computation or variable
assignment
It indicates a decision to be made. The
Decision program should continue along one of
two routes the Yes(True) or No (False)
On-Page Connector It is used to connect or join a flow lines
Off-Page Connector It is used to indicate that the flowchart
continues to second page
PROGRAM STRUCTURES
Program Structure is the structure used by the
programmer to identify the task to be done using a
different algorithm or design tools. This is the
sequence, selection and repetition structures. These
structures can be used in Algorithm, Pseudocode or
Flowchart.
SEQUENCE
A series of instruction in a
series of sequence or
instructions followed by
another instruction.
SAMPLE SEQUENTIAL
Sample Problem:
You and your friends plans to go on picnic and decide
to share the expenses among them. The total
expenses is calculated as the sum of transportation
and food expenses.The share amount of picnic
expenses is calculated as the total expense over the
number of every individual joined the picnic.
Pseudocode
Step 1: Input total_num_of_individual, transpo_expenses,
food_expenses
Step 2:total_expenses = transpo_expenses +
food_expenses
Step 3: total_share_amount_of_picnic_expenses
= total_expenses /
total_num_of_individual Step 4: Display
total_share_amount_of_picnic_expenses Step
5: End
Sample Problem:
You and your friends plans to go on picnic and decide
Star
to share the expenses among them. The total t
expenses is calculated as the sum of transportation
and food expenses.The share amount of picnic
Input
expenses is calculated as the total expense over the total_num_of_indivi
number of every individual joined the picnic. dual,
transpo_expenses,
food_expenses
Pseudocode
total_expenses = transpo_expenses
+
Step 1: Input total_num_of_individual, transpo_expenses, food_expenses
food_expenses
total_share_amount_of_picnic_expenses
Step 2:total_expenses = transpo_expenses + = total_expenses /
total_num_of_individual
food_expenses
Step 3: total_share_amount_of_picnic_expenses
Display
= total_expenses / total_share_amount
total_num_of_individual Step 4: Display
total_share_amount_of_picnic_expenses Step En
d
5: End
Star
t
Problem:
Arithmetic operation that will add two
numbers. Input/Read N1,
N2
Pseudocode
Sum = N1 + N2
Step 1: Start
Step 2: Input/Read N1, N2
Display/
Step 3: Sum = N1 + N2 Print the
total Sum
Step 4: Display/Print the total
sum
En
Step 5: End d
SELECTION
One of two possible
actions are taken,
depending on a condition
SELECTION
A new symbol, the diamond,
indicates a yes/no question. If
the answer to the question
is yes,
flow the one pat If
follows
answer is no, the h. the
another path flow follow
s
SELECTION
In the flowchart segment
below, the question “is x <
y?” is asked. If the answer is
no, then process A is
performed. If the answer is
yes, then process B is
performed.
SAMPLE SELECTION
int num=12;
if(num<100){
cout << num <<“is less than 100";
}
int num=12;
if(num%2==0){
count << "num is even number";
}else{
cout << "num is odd number";
}
int num=12;
if(num%2==0){
count << "num is even number";
}else{
cout << "num is odd number";
}
int marks=69;
if ( marks<75){
echo “Failed";
}
else if (marks>=76 && marks<85) {
echo “Good";
}
else if (marks>=86 && marks<90) {
echo “Very Good";
}
else if (marks>=95 && marks<100) {
echo “Excellent";
}
else {
echo "Invalid input";
}
int age = 23;
string nationality = "Philippines";
if (nationality == “Filipino")
{
if (age >= 18) {
echo "Eligible to give vote";
}
else {
echo "Not eligible to give vote";
}
}
?>
Start
int age = 23; Read
age, nationality
string nationality = "Filipino";
if ( nationality == “Filipino")
{ nationality T
==
cout<< “Applicable” “Filipino”
}
else F
{
cout<< “Not Applicable"; Display
} Applicable
?>
Display
Not Applicable
End
Start
Read
age, nationality
int age = 23;
nationality T T
string nationality = "Filipino"; == age>=18
if (nationality == “Filipino") “Filipino”
{ F Display
if (age >= 18) { F
Eligible to vote
cout<< "Eligible to give vote";
}
Display
else { Not Eligible to
cout<< "Not eligible to give vote"; vote
}
}
Display
?> Not Applicable
End
Start
nationality
string nationality = “Filipino";
if ( nationality == " Filipino")
{ nationality T
== T
int age = 23; “Filipino”
Input age age>=18
if ( age >= 18) {
cout<< "Eligible to vote"; F F Display
Eligible to vote
}
else {
Display
cout<< "Not eligible to Not Eligible to
vote"; vote
}
} Display
else Not Applicable
{
cout<< “Not Applicable";
}
?> End
int age = 23;
string nationality = "Philippines";
if (nationality == "Philippines")
{
if (age >= 18) {
echo "Eligible to give vote";
}
else {
echo "Not eligible to give vote";
}
}
?>
Start
int age = 23; age
nationality
string nationality = "Philippines";
if ( nationality == "Philippines")
{ nationality T
== age<18
if ( age < 18) { “Philippines”
echo “Not Eligible to vote"; T
} F
if ( age >= 18) { age>=18
echo “Eligible to vote";
Display T
} Not Eligible to
} vote
Display
else Eligible to
vote
{ Display
Not Applicable
echo “Not Applicable";
}
End
Star
t
Problem:
Write an algorithm to find the greater number Input
between two numbers . Assume that the two A,B
value is A and B
Pseudocode Ye N
s If (A > o
B)
Step1: Start
Step 2: Input A,B Display Display
“ A is “ B is
Step 3: If (A > B) greater greater
than B” than A”
Ye Display “ A is greater
s
than B”
els
e
N Display “B is greater
o En
than A”
Step 4: d
End
Problem: Star
t
Determine a student’s final grade and indicate
whether it is passing or failing.The final grade is
Input M1, M2, M3,
calculated as the average of four M4
Pseudocode
GRADE = (M1+M2+M3+M4)/4
Step 1: Start
Step 2: Input M1, M2, M3, M4
Ye N
Step 3: GRADE = (M1+M2+M3+M4)/4 s
if
(GRADE >= o
50)
Step 4: if (GRADE greater than or equal to
50)
Print
“Pass”
els Print Print
“Pass” “Fail”
e
Print
“Fail”
Step 5:
End
En
d
Pseudocode
Find the maximum of two numbers
num1 = 10
num2 = 20
if num1 > num2 then
max = num1
else
max = num2
display "The maximum number is ", max
Pseudocode
1. Set the variable x to 5
2. Set the variable y to 10
3. Set the variable z to 0
4. If x is greater than y, then:
5. Set z to x + y
6. Print "x is greater than y"
Else if x is equal to y, then:
7. Set z to x - y
8. Print "x is equal to y"
Else:
9. Set z to y - x
10. Print "x is less than y"
11. Print "The value of z is: " + z
REPETITION
A repetition structure
represents part of the
program that repeats. This
type of structure is
commonly known as a loop.
REPETITION
Notice the use of the
diamond symbol. A loop tests
a condition, and if the
condition exists, it performs
an action.
Then it tests the condition
again. If the condition still
exists, the action is repeated.
REPETITION
In the flowchart segment, the
question “is x < y?” is asked. If
the answer is yes, then Process A
is performed. The question “is x
< y?” is asked again. Process A is
repeated as long as x is less
than y. W hen x is no longer
less than y, the repetition stops
and the structure is terminated.
REPETITION
The action performed by a
repetition structure must
eventually cause the loop to
terminate. Otherwise, an infinite
loop is created. In this flowchart
segment, x is never changed.
O nce the loop starts, it will
never end.
REPETITION
QUESTION:
How can this flowchart be
modified so it is no longer an
infinite loop?
ANSWER:
By adding an action within the
repetition that changes the
value of x.
SAMPLE REPETITION
Star
Problem: t
Assign the count to 1 and display number from 1 to
10, then stop when such a number is given Count = 1
Detailed A lgorithm
T ru
Step 1: Start e count
<=10
Step 2: count = 1 (Assigned Value to
count) Fals
e
Step 3: while count <= 10
Step 4: Display count Display
count
T ru Step 5: count = count
e
+ 1 Step 6: return to
count = count +
step 3
Fals Step 7: 1
e
End
En
d
Star
Problem: t
To keep asking for a password, and to give the
message " Login Successfully " when the correct
Enter
password is given. Password
Detailed A lgorithm
Step 1: Start N
Password = o
Step 2: Enter password “Admin”
Step 3: password ==
“Admin” Ye
N Step 4: return to step 2 s
o
Step 5: display “Login Successfully” Display
Ye Login Successfully
s
Step 6:
End
En
d
Star
Problem: t
To keep asking for a password, and to give the
message " Login Successfully " when the correct
Enter
password is given. Password
Login Failed,
Detailed A lgorithm Try Again
N
Step 1: Start o
Password =
Step 2: Enter password “Admin”
Step 3: password == “Admin”
Ye
N Step 5: “Login Failed, Try Again” s
o
Step 5: Enter password Display
Login Successfully
Ye Step 6: display “Login Successfully”
s
Step 7:
End
En
d