Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Pseudocode

Introduction
Pseudo code is a combination of two words Pseudo and Code.’Pseudo’ means imitation and ‘code’ refer to
instruction written in the programming language.Pseudo code is not a real programming language.It is the
generic way of describing an algorithm without using any specific programming language-related notations.

Purpose- to define the procedural logic of an algorithm in a simple, easy-to- understand for its readers.
Consists of natural language-like statements that precisely describe the steps of an algorithm or program.
Pseudo code cannot be compiled and executed and there are no real formatting or syntax rules for writing
pseudo codes.

Features of Pseudocode
1. It uses plain English statements
2. It emphasizes on the design of the computer program
3. Focuses on the logic of the algorithm or program
4. It uses Structured English
5. Avoids language-specific elements
6. It is detailed and readable to draw an inference
7. It enables the programmers to concentrate on the algorithms.
8. Free of syntactical complications of programming language.

Preparing a pseudo code:

1. Pseudo code is written using structured English.


2. In a pseudo code, some terms are commonly used to represent the various actions.
3. For example, for inputting data the terms may be (INPUT,GET, READ,OBTAIN), for outputting data
( OUTPUT, PRINT, DISPLAY), for calculations ( COMPUTE, CALCULATE,DETERMINE), for
incrementing ( INCREMENT), initialization-INITIALIZE,SET.
4. ADD, SUBTRACT used for addition and subtraction
5. For conditional statements uses terms like IF, ELSE, ENDIF and looping statements like WHILE, DO
WHILE etc.
Pseudo code Examples
Major constructions in pseudo code structures are sequence and selection(decision).sequence indicates the
continuous flow of the program,whereas selection uses logical comparison or conditional check for making
decisions.

Example:
IF(condition) THEN
List of Actions
ELSE
List of different Actions
END IF

1. Example: pseudo code for Multiplying two numbers


READ a,b
COMPUTE C=a*b
PRINT C
STOP

2. Example: pseudo code for greatest of three numbers

READ a,b,c

IF (a>b) and (a>c) THEN

WRITE a is big

ELSE IF (B>C) THEN

WRITE b is big

ELSE

WRITE c is big

END IF
3. Example: find sum of first 100 integers

INITIALIZE SUM to zero

INITIALIZE I to zero

DO WHILE (I <100)

INCREMENT I

ADD I to SUM and store in SUM

END DO WHILE

PRINT SUM

STOP

Advantages of Pseudo code

1. Since,it is language independent,it can be used by most programmers


2. It is easier to develop the program from pseudo code than with a flowchart
3. It is easier to translate to the programming language
4. Its simple structure and readability makes it easier to modify as well

Disadvantages of Pseudo code

1. It does not provide the visual representation of the program logic


2. There are no accepted standards for writing pseudo code

You might also like