4 the Pseudocode Algorithm
4 the Pseudocode Algorithm
Program Design
Algorithms(Pseudocode)
OBJECTIVES
▪ Algorithm header:
▪ Name
▪ author
▪ date
▪ description
▪ Declaration:
▪ Start
– Body
▪ Stop
Pseudocode: Product_of_three_numbers} Algorithm
Author/Developer: Ms Miller header
Date: December 2020 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
Read num2
Read two numbers, find the sum of the
numbers and output the sum of the numbers
Or
Accept NUM1,NUM2
STATEMENTS:ASSIGNMENT STATEMENT
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
▪ For example, if you were required to read two numbers, find the sum
of the numbers and output the sum of the numbers. The output
statement would be:
or
Print sum
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
sum of 3 numbers
Problem Solving and
Program Design
Algorithms(Pseudocode with IF construct)
OBJECTIVES
General objective(s):
▪ Understand when and how to include IF
statement within a pseudocode algorithm.
Selection
Repetition
CONTROL STATEMENTS
▪ Sequence
– This is the structure that allows statements to be executed in the
order in which they are written in your program. Each statement
will only be executed once by the computer.
▪ Selection
– This control structures allow for decisions to be made in a
program based on a condition. Examples of those constructs are
the IF-THEN statement and the IF-THEN-ELSE statement.
▪ Repetition
– This allows statements to be repeated a fix number of time until
some condition evaluates to be false.
Assignment
The IF-Then Statement suggest that one or more statements will only
be considered based on a condition or the answer to the question