Beruflich Dokumente
Kultur Dokumente
Flowcharting and
Pseudo-coding
Engr. J. Cansino
Examples:
10 -28 +3.4 -0.413 0 201
Arithmetic Expressions
Hierarchy or Priority of Operators
1.) Expressions in parenthesis
2.) * / %
3.) + -
Examples:
3.) 20 / 4 * 9
1.) 10 + 4 * 8
5
32
42 45
2.) 50 % 6 – 5
2
-3
String Expressions
Examples:
1.) “3” + “4” = “34”
2.) “Ja ” + “red” = ”Jared”
Examples:
X !X
FALSE TRUE
TRUE FALSE
TRUTH TABLE FOR AND(&&)
X Y X && Y
FALSE FALSE FALSE
FALSE TRUE FALSE
TRUE FALSE FALSE
TRUE TRUE TRUE
X Y X || Y
FALSE FALSE FALSE
FALSE TRUE TRUE
TRUE FALSE TRUE
TRUE TRUE TRUE
Examples:
15 >= 10 && 15 <= 20
T && T
T
TYPES OF FLOWCHARTS
1.) System Flowchart – present the total picture
without worrying about taking care of every detail.
2.) Program Flowcharts – depicts a main segment of
a complete computer program.
FLOWCHARTING GUIDELINES
1.) Always use the ANSI standard symbols.
2.) Construct your flowcharts to read from top to
bottom and left to right.
3.) Do not crisscross flowlines (used labeled
connectors and use arrowheads to indicate direction
of the flow.
4.) Make the messages and labels in the flowchart
symbol direct and descriptive.
5.) Strive for neatness, clarity and simplicity.
BASIC FLOWCHARTING SYMBOLS
Terminal Symbol
Preparation Symbol
Processing Symbol
Decision Symbol
Input/Output Symbol
Onpage Connector
Offpage Connector
Terminal symbol
I/O symbol
Preparation symbol
Direction lines
For Pseudocode, keywords used are the following:
1.) Accept
Syntax: Accept <variable>
Accept <variable1>, …, <variableN>
2.) Display
Syntax: Display “<string>”
Display <variable>
Display <variable1>, …, <variableN>
Sequential structure
#1] Input a temperature in Celsius and
output the corresponding temperature in
Fahrenheit. The formula is a follows:
Fahrenheit = 9 (Celsius) + 32
5
Pseudocode
Flowchart
Variables Used:
Start
F, C are numeric
F=0 Begin
Input C
F=0
Display ” Input temperature in Celsius: ”
F = (9.0/5.0) * C + 32 Accept C
F = (9.0 / 5.0) * C + 32
Output F
Display “Equivalent temperature in
Fahrenheit:”, F
End
End
Sequential structure
#2] Pepperoni++ Pizza House charges 10%
service charge and 5% sales tax on the gross
bill of the customer. Create a flowchart and a
pseudocode that would input the gross bill of the
customer and the amount given by the customer
to the waiter. It must output the customer’s total
bill and change (if there’s any).
Flowchart Pseudocode
Start Variables Used:
GBill, Amt, change, TBill are numeric
TBill = 0 Begin
change = 0
TBill = 0
Terminal symbol
I/O symbol
Preparation symbol
Decision symbol
For Pseudocode, keywords used are the
following:
1.) Accept
Syntax: Accept <variable>
Accept <variable1>, …, <variableN>
2.) Display
Syntax: Display “<string>”
Display <variable>
Display <variable1>, …, <variableN>
3.) if-then-else
Syntax #1: if <condition> then
begin
statements
.
.
.
end
else
begin
statements
.
.
.
end
Syntax #2: if <condition1> then
begin
statements
end
else if <condition2> then
begin
statements
end
else if <conditionN> then
begin
statements
end
else
begin
statements
end
Selection/Conditional Structure
#1] Using Visual Logic, create a
flowchart and a pseudo-code that
will prompt the user to input two
number and output the highest
number entered.
Flowchart Start
Input N1, N2
Y
If
Output N1 A
N1 > N2
N
Output N2
A
End
Pseudocode
Variables Used:
N1, N2 are numeric
Begin
Display ” Input two numbers: ”
Accept N1, N2
if (N1 > N2) then
Display N1
else
Display N2
End
Assignment # 1 .3 Selection Structure
#1] The fine for an over-speeding violation depends on the
speed of the erring driver, as follows:
60 to 75 mph = Php 2000.00
76 mph and above = Php 4000.00
Create a flowchart and a pseudocode to input the car’s
speed and then output the fine, if any.
I/O symbol
Preparation symbol
Decision symbol
For Pseudo code, keywords used are the following:
1.) Accept
2.) Display
3.) if-then, if-then-else
4.) while-do
Syntax:
while <condition> do
begin
statements;
.
.
end .
Iterative Program Structure
#1] Create a flowchart/pseudo code that will
generate the following number series:
Output X, Y
X=X–1
Y=Y+5
Y
If
X >= 6
N
End
Pseudo code
Variables Used:
X, Y are numeric
Begin
X = 10
Y=5
while (X >= 6) do
begin
Display X, Y
X=X–1
Y=Y+5
end
End
Iterative Program Structure
#2] Create a flowchart/pseudo code that will
generate the following number series:
Output Sum
Sum = X + Y
X=Y
Y = Sum
Y
If
Sum <= 55
N
End
Pseudo code
Variables Used:
X, Y, Sum are numeric
Begin
X=0
Y=1
Sum = 1
while (Sum <= 55) do
begin
Display Sum
Sum = X + Y
X=Y
Y = Sum
end
End
Assignment #1.4 Iterative Program Structure