0% found this document useful (0 votes)
51 views15 pages

Problem Solving and Program Design - Pseudocode 1 20240206 - Updated

The document provides an overview of pseudo-code, including its definition, characteristics, and types of statements used. It outlines the structure of pseudo-code, emphasizing its role as an intermediary between algorithms and high-level programming languages. Additionally, it includes examples of writing pseudo-code for various problems involving input, output, and assignment statements.

Uploaded by

Kcrystalll
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views15 pages

Problem Solving and Program Design - Pseudocode 1 20240206 - Updated

The document provides an overview of pseudo-code, including its definition, characteristics, and types of statements used. It outlines the structure of pseudo-code, emphasizing its role as an intermediary between algorithms and high-level programming languages. Additionally, it includes examples of writing pseudo-code for various problems involving input, output, and assignment statements.

Uploaded by

Kcrystalll
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Problem

Solving Presented by

and Hugh-Hing Lawrence

Program
Design
Specific Objective
Define Define the term pseudo-code.

Describe Describe the characteristics of a valid pseudo-code

Identify types of statement used in pseudo-code (sequence, selection


Identify or conditional, loop or iteration or repetition)

State terms that are used to represent each type of statement


State mentioned in object number four

Write pseudo-codes which require the use of output, input and


Write assignment statements

Solve simple problem the requires the use of statement in objective


Solve number 9

Created by: HR. Lawrence


The prefix pseudo means
imitation or false

A Pseudo-code is an
PSEUDOCODE imitation computer
program

A pseusodo-code cannot
be executed in a high
level programming
language

Created by: HR. Lawrence


combines some of the
constructs of
programming language,
with a natural language,
such as plain English.

PSEUDOCODE
cont…
is the intermediary
between an algorithm
and a high level
programming
language

Created by: HR. Lawrence


Finite number of steps

Precise

Characteristics Unambiguous
of a
Pseudocode
Control flow from one process
to another

Terminate

Created by: HR. Lawrence


Statements Used in Pseudocode

Sequence

• Output
• Input
• Assignment

Selection / Conditional/Branching

Iteration / Loop / Repetitive

Created by: HR. Lawrence


Terms Used in Pseudocode

INPUT PROCESS OUTPUT STORAGE


INPUT SET PRINT WRITE
READ LET DISPLAY ASSIGN
GET WRITE

Created by: HR. Lawrence


Used to display messages to the
user OR the result of processing

DISPLAY
The general format “Expression”
of an output DISPLAY
“Expression”,
statement is: <variable_name>

OUTPUT
e.g. DISPLAY “Welcome to
Program Design”

e.g. DISPLAY “The Average Score


is”, average

Created by: HR. Lawrence


Allows the user to enter data;
normally at a prompt.

INPUT The keyword is INPUT

STATEMENT

Format INPUT <variable_name>

Created by: HR. Lawrence


ASSIGNMENT STATEMENTS
 Used to give initial value or change the value
during execution.
 The assignment operator is 
 General Format:

<variable_name>  <value>

Storage location Contents

 Example, Score  78
Created by: HR. Lawrence
Question: Write an algorithm to accept values in
ASSIGNMENT the variables p, m and n and calculate the
sum, product and average.
STATEMENTS
cont… Solution:
START
DISPLAY “Enter the first value”
INPUT p
DISPLAY “Enter the second value”
INPUT m
DISPLAY “Enter the third value”
INPUT n
Sum  p + m + n
Product  p * m * n
Average  (sum / 3)
STOP

Created by: HR. Lawrence


Accept the length and width of a
rectangle and calculate the area and
perimeter.

Accept the name, unit price, quantity


of an item and calculate the total to
be paid

Write
Pseudocode
to: Accept and interchange values in the
variables a and b.

…to prompt a user to enter radius of a


circle then calculate and display the
area and circumference. Use PI as
3.142

Created by: HR. Lawrence


Prompt a user to enter radius of a
circle then calculate and display
the area and circumference. Use
PI as 3.142.

Write
pseudocode
that will:

Prompt a user to enter the name,


hourly rate, hours worked, calculate
the gross salary and the net salary
after 10% tax is subtracted
Created by: HR. Lawrence
START
TAXRATE = 0.1
Solution… DISPLAY “Enter Name “
INPUT name
DISPLAY “Enter Hours Worked “
INPUT hWorked
DISPLAY “Enter Hourly Rate“
INPUT hRate
gPay  hWorked * hRate
Tax  gPay * TAXRATE
nPay  gPay – tax
STOP

Created by: HR. Lawrence


Questions Question or comment?

You might also like