Problem Solving and
Program Design
Algorithms(Pseudocode)
OBJECTIVES
1. State the purpose of a pseudocode
2. State the keywords used for input statements, output
statements and assignment statements
3. Identify the parts of a Pseudocode algorithm.
Research the following
a. State the purpose of a pseudocode
b. Identify the parts of a Pseudocode algorithm.
c. State the keywords used for input statements, output statements
and assignment statements
d. Represent algorithms in the form of pseudocode
WHAT IS A PSEUDOCODE?
▪ A pseudocode is not a programming code, but uses English-type
words and phrases that are clear enough to be easily converted into a
programming code.
▪ Pseudocode can be developed from an IPO Chart to specify what data
is input and processed into information.
▪ One of three (3) ways to represent an algorithm.
– Pseudocode Algorithm
– Flowchart
– Narrative
WHAT IS THE PURPOSE OF A
PSEUDOCODE?
▪ Pseudocode is sometimes used as a detailed step in the
process of developing a program.
▪ It allows designers or lead programmers to express the
design in great detail and provides programmers a
detailed template for the next step of writing code in a
specific programming language.
Pseudocode: Product_of_three_numbers} Algorithm
Author/Developer: Ms Miller header
Date: December 2022 Documentatio
n
{This algorithm find the product of 3 numbers} Pseudocode
Description
Declare num1, num2,num3. product as integer Variable Declaration
Start
Print “Please enter three numbers”
Read num1, num2, num3 Input Statement
Product num1 * num2* num3 Assignment
Statement
Print “The product is: ” , Product Output /prompt
Statement
Stop Termination.
PSEUDOCODE:STATEMENTS & KEYWORDS
▪ A statement is a description of the processing that can be
included in an action or condition.
▪ Instruction within the statements are called keywords.
▪ Examples of keywords are INPUT, READ, OUTPUT, DISPLAY,
PRINT or WRITE.
▪ In the development of a Pseudocode, there are three types
of Statements to consider:
1. Input Statement
2. Assignment Statements
3. Output Statements
Pseudocode: Product_of_three_numbers} Algorithm
Author/Developer: Ms Miller header
Date: December 2022 Documentatio
n
{This algorithm find the average of 3 numbers} Pseudocode
Description
Declare num1, num2,num3. product as integer Variable Declaration
Start
Print “Please enter three numbers”
Read num1, num2, num3 Input Statement
Product num1 * num2* num3 Assignment
Statement
Print “The product is: ” , Product Output /prompt
Statement
Stop Termination.
PSEUDOCODE:STATEMENTS
Read num1 Input
Statement
Read num2
sum num1 + num2 Assignment
Statement
Print “The sum of the numbers is”, sum
Output/prompt
Statement
STATEMENTS:INPUT STATEMENT
▪ The input statement provides the data required for
processing or calculation by the program.
▪ Example of input statement: Read num1
▪ Question:Accept two numbers and print the total . The
input statement would be:
Read num1
Read num2
Accept two numbers and print the
total
IPO CHART: INPUT PSUEDOCODE: INPUT
INPUT
Read num1
Accept three
numbers
NUM1 Read num2
NUM2
Or
Accept NUM1,NUM2
STATEMENTS:ASSIGNMENT STATEMENT
▪ The assignment statements expresses the
calculation/processing of the data entered/provided.
▪ Example of Assignment Statement:
▪ sum num1 + num2
▪ Some assignment statements may also reflect the
assigning of values to variables, such as:
▪ Count 1
Highest_Price 0
Read two numbers, find the sum of the
numbers and output the sum of the numbers
PSUEDOCODE:
IPO CHART: Processing
Assignment Statement
PROCESSING
sum
1. Accept num1 + num2
NUM1,NUM2
2.Calculate total
TOTAL NUM1
+NUM2+NUM3
3. Print TOTAL
ARITHMETIC OPERATORS
ARITHMETIC OPERATORS EXAMPLES
Addition ( +) TotalPay= BasicPay+Bonus
Subtraction ( - ) NetPay=TotalPay-Tax
Multiplication ( * ) Days=Weeks*7
Division ( / ) Days=Hours/24
DIV- The operator DIV gives the result of integer Result =20 DIV 8
division, but not the remainder.
The variable “Result” would hold the value 2.
MOD-The operator MOD gives the remainder. Remainder= 20 MOD 8
The variable “Remainder” would hold
the value 4.
STATEMENTS:OUTPUT STATEMENT
▪ These statements provide/display the result of the
calculation/processing of the input given. They are also
known as prompting statements.
▪ Example: Accept two numbers and print the total . The
output statement would be:
– Print “The sum of the numbers is ” , sum
▪ If you are prompting the user to enter data, the output
statement would be
▪ Print “Enter two numbers”
▪ Double quotes are important with output statements.
Read two numbers, find the sum of the
numbers and output the sum of the numbers
PSUEDOCODE: Output
IPO CHART: Output
Statement
OUTPUT
Print “The sum of the numbers
is”, sum
Print TOTAL
Create an algorithm
which calculates the
average of 3 numbers