Pseudocode Handout
Pseudocode Handout
Pseudocode
Student Name:
Once the algorithm is tested in pseudocode or program flowchart then finally it is written in a
specific programming language.
Pseudocode is a false code which consists of plain English statements, mathematical notations
and keywords that are commonly found in high level languages.
It does not follow strict rules and style of any particular programming language. Pseudocode is
used for learning programming concepts and to describe ideas before coding begins.
1. What is Pseudocode?
- Pseudocode is a way of planning and describing a computer algorithm using simple, human-
readable language.
- It uses structured English-like phrases to outline the logic of a program without getting into the
specifics of programming languages.
Certainly! Let's break down the advantages, disadvantages, characteristics, and keywords related
to pseudocode:
Advantages of Pseudocode:
1
1. Simplicity: Pseudocode uses plain language and simple constructs that are easy to understand
and write.
2. Clarity: It helps in visualizing the structure of an algorithm without being concerned about
syntax rules of a particular programming language.
3. Ease of Modification: Changes and improvements to algorithms can be made quickly and
without the overhead of actual coding.
5. Planning Aid: It serves as a planning tool, allowing developers to design and refine algorithms
before implementation.
Disadvantages of Pseudocode:
1. Ambiguity: Sometimes pseudocode can be interpreted differently by different individuals,
leading to misunderstandings.
2. Not Standardize: There are no strict rules or standards for writing pseudocode, which can lead
to inconsistency across different pseudocode documents.
3. Limited Detail: It may not capture all nuances or edge cases that need to be considered in
actual coding.
Characteristics of Pseudocode:
1. Language-Independent: Pseudocode is not tied to any specific programming language,
allowing for flexibility and universality in its use.
2. Structured: It follows a structured approach, often resembling a mix of natural language and
programming constructs (like conditionals, loops, and variables).
3. Abstraction: It abstracts away low-level details, focusing on the algorithmic logic and flow of a
program.
2
1. DECLARE: Used to declare variables.
10. REPEAT-UNTIL: Looping construct that repeats a block of code until a condition is met.
Operators
ARITHMETIC OPERATORS:
In pseudocode arithmetic operators are used to perform arithmetic operations. These operators
are listed below:
Arithmetic Operator
Meaning
+ Addition
- Subtraction
*
Multiplication
/
Division
COMPARISION OPERATORS:
3
These operators are used to compare different values.
Assignment Operator:
Assignment operator is used to assign the value or expression to a variable. The value or
expression is on the right side of the assignment operator while the variable is on the left side
of the assignment operator.
INPUT in Pseudocode:
In pseudocode we indicate the operation of taking input from users by either of the following
keywords:
4
● INPUT
● READ
● ENTER
OUTPUT:
In pseudocode we indicate the operation of displaying a value or an output or any message by
using either of the following keywords:
· OUTPUT
· WRITE
Note:
In CIE exam, mostly INPUT, OUTPUT and READ, WRITE keywords are used
VARIABLE:
It is a named memory space which is used to store values. Variable usually stores two kind of
information:
1. All the input values from user must be stored in a variable
2. Result of some mathematical operation must be stored in a variable.
Example 1: Write Pseudocode that will take two numbers as input, calculates their sum and displays
output.
Solution:
WRITE “Please enter two numbers to add”
READ num1
READ num2
5
Sum ß num1+num2 WRITE Sum
In the above written pseudocode, num1 and num2 are the variable names where the two input
number given by user will get store. The sum of num1 and num2 is a mathematical operation and
the answer is saved in a variable named as sum. It is not necessary that name of variable should be
same but it should be relevant. For example, the variable name Sum could be answer, ans, result
etc.
Example 3: Write down Pseudocode that will take marks of physics, chemistry and math as input,
calculates the average and displays output.
Solution:
WRITE “please enter marks of physics” READ Phy_marks
WRITE “please enter marks of chemistry” READ Chem_marks
WRITE “please enter marks of maths” READ math_marks
Avg ß (Phy_marks + Chem_marks + math_marks)/3 WRITE Avg