Definition

  • Pseudo-code is a compact and informal high level description of a computer programming algorithm that uses the structural conventions of some programming language.

Characterstics

  • Pseudo-code typically omits details that are not essential for understanding the algorithm, such as functions (or subroutines), variable declaration, semicolons, special words and so on.
  • Pseudo-code is independent of any programming language.
  • Pseudo-code cannot be compiled nor executed, and not following any syntax rules.
  • In fact, one can write a pseudo-code for any given problem without even knowing what programming language one will use for the final implementation.

Objectives

  • The purpose of using pseudo-code is that it is easier to read than conventional programming languages that enables (or helps) the programmers to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language.

Rules/Conventions to create a Pseudocode:

The following conventions must be used during the creation of pseudo-code. These are –

  • Give a valid name for the pseudo-code procedure, initially.
  • Use the line numbers(not step wise as in algorithm) for each line of code.
  • Use proper Indentation for every statement in a block structure to represent well.
  • For a flow control statements, use if-else and always close with an end-if. Both if, else and end-if should be aligned vertically in same line.
 if (expression)
statements
else
statements
end if
We can separate two or more conditions with ‘and’ word.
  • Use = or ← operator symbol for assignment operation, if any.
  • In Pseduocode, array elements can be represented by specifying the array name followed by the index in square brackets. For example, A[i] indicates the ith element of the array A.
  • In the case of looping or iteration statements, use for or while statements and always end a for loop with end-for and a while with end-while.
  • Wherever required, we can also put comments symbol( /* ….  */) in between.

For Example

The pseudo-code for finding the maximum of three numbers are –

Input parameters(a,b,c)
Output parameters(x)
FindMax(a,b,c,x)
{
x=a
if(b>x)
x=b
if(c>x)
x=c
}

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.