Pseudocode Handout
Pseudocode Handout
Unit 2: 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:
1
Advantages of Pseudocode:
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
Keywords Used in Pseudocode:
1. DECLARE: Used to declare variables.
10. REPEAT-UNTIL: Looping construct that repeats a block of code until a condition is met.
3
Operators
ARITHMETIC OPERATORS:
In pseudocode arithmetic operators are used to perform arithmetic operations. These operators
are listed below:
+ Addition
- Subtraction
* Multiplication
/ Division
COMPARISION OPERATORS:
These operators are used to compare different values.
4
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:
● 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
● PRINT
Note:
In CIE exam, mostly INPUT, OUTPUT and READ, WRITE keywords are used
5
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:
In the above written pseudocode, num1 and num2 are the variable names where the two input
numbers given by the user will get stored. 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 the name of the
variable should be the same but it should be relevant. For example, the variable name Sum could
be answer, ans, result etc.
6
Example 2 : Write down Pseudocode that will take marks of physics, chemistry and math as
input, calculates the average and displays output.
Solution:
INPUT number
If number mod = 0
Else