You are on page 1of 18

Using Pseudocode

Statements
LESSON 2
Pseudocode
 an English-like representation of the
logical steps it takes to solve a problem
 pseudo means false, code is a
instructions using a programming
language
 Pseudocode simply means false code
Example
Writing Pseudocode
Number-doubling program
start Beginning Statement
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop Terminating Statement
Writing
Pseudocode
Function Other terms
start begin
stop end
input get or read

set calculate, compute

output display, print or write


Pseudocode Standards
1. Programs begin with start and end with stop;
these two words are always aligned.
2. Whenever a module name is used, it is followed
by a set of parentheses.
3. Modules begin with the module name and end
with return. The module name and return are
always aligned.
4. Each program statement performs one action—
for example, input, processing, or output.
Pseudocode Standards
5. Program statements are indented a few spaces
more than start or the module name.
6. Each program statement appears on a single
line if possible. When this is not possible,
continuation lines are indented.
7. Program statements begin with lowercase
letters.
8. No punctuation is used to end statements.
MATHEMATICAL OPERATIONS
PARENTHESIS / ES (Grouping) ()
CARET (Exponent) ^
ASTERISK (Multiplication) *
SLASH (Division) /
PLUS SIGN (Addition) +
MINUS SIGN or DASH (Subtraction) -
EQUAL SIGN (Assignment) =
Let’s do it! #1
Write a pseudocode to represent
the logic of a program that allows
users to enter a value. The program
divides the value by 2 and outputs
the result.
Use variables anyNumber for the
input and quotient for the output
Let’s do it! #1 - Output

Please enter any number: 2


The quotient is: 1
Let’s do it! #1 - Answer

start
output “Please enter any number:”
input anyNumber
set quotient = anyNumber/2
output “The quotient is: ”
output quotient
stop
Seatwork 1

Write a pseudocode to
represent the logic of a
program that allows users to
enter two values. The
program outputs the product
of the two values.
Seatwork 2

Write a pseudocode to represent the


logic of a program that allows the user
to enter the grades in 5 subjects namely:
English, Math, Science, AP and TVE. The
program will calculate the general
average of the student. The program
outputs the result.
Group Activity
I – LOVE – PSEU – DO – CODE
Write a pseudocode to represent the logic of a
program that allows the user to enter 3 values for
the length of the 3 sides of a rectangular prism.
The program calculates the Surface Area of a
Rectangular Prism with the formula 2ab + 2bc +
2ac.The program outputs the result.
Group Activity

Variables
 sideA
 sideB
 sideC
 surfaceArea
Sample Output

Enter the length of the first side:


Enter the length of the second side:
Enter the length of the third side:
The Surface Area is:
Answer
start
output “Enter the length of the first side:”
input sideA
output “Enter the length of the second side:”
input sideB
output “Enter the length of the third side:”
input sideC
set surfaceArea = (2 * sideA * sideB) + (2 * sideB * sideC) + (2 * sideA *
sideC)
output “The Surface Area is: ”
output surfaceArea
stop
HOMEWORK

Write a pseudocode to represent the logic of a


program that allows the user to enter 3 values for
the length of the 3 sides of a rectangular prism.
The program calculates the Surface Area of a
Rectangular Prism with the formula 2ab + 2bc +
2ac.The program outputs the result.

You might also like