0% found this document useful (0 votes)
46 views7 pages

Pseudocode Handout

Uploaded by

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

Pseudocode Handout

Uploaded by

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

THE INDIAN PUBLIC SCHOOL - CAMBRIDGE INTERNATIONAL

Pseudocode

Student Name:

Grade & Sec:


Algorithms are step by step solutions to a given problem. It is written in plain English
statements. Algorithms are usually transformed into pseudocode or program flowchart.

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.

2. Why Use Pseudocode?


- It helps in understanding and planning algorithms before writing actual code.

- It can be easily understood by anyone, regardless of their programming background.

- It serves as a bridge between problem-solving ideas and actual coding.

Certainly! Let's break down the advantages, disadvantages, characteristics, and keywords related
to pseudocode:

There are 3 programming/pseudocode constructs:


1. Sequence: It refers to instructions that should be executed one after another.
2. Selection: This construct is used to make a decision in choosing an option from many available
options on the basis of a condition. So, if a condition is true then one option would be chosen
while if a condition is false then another option will be chosen.
3. Repetition: This construct is used to repeat a block of code as per the given condition.

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.

4. Universal Understanding: Pseudocode can be understood by programmers and non-


programmers alike, facilitating collaboration and communication.

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.

4. Readability: Pseudocode aims to be easily readable and understandable by anyone familiar


with basic programming concepts.

Keywords Used in Pseudocode:

2
1. DECLARE: Used to declare variables.

2. SET: Assigns a value to a variable.

3. INPUT: Reads data from a user or an input device.

4. OUTPUT: Displays data to a user or an output device.

5. IF-THEN-ELSE: Conditional statement for decision-making.

6. FOR, WHILE, DO-WHILE: Keywords for looping constructs.

7. FUNCTION, PROCEDURE: Used to define modular blocks of code.

8. RETURN: Specifies the output of a function or procedure.

9. BEGIN, END: Denotes the beginning and end of a block of code.

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

^ Show power of a number

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

· PRINT

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.

These are the rules while assigning name to a variable:

· There is no space in a variable name

· Variable name should not be a keyword of pseudocode

· Variable name should be relevant.

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

You might also like