Algorithms Pseudo Code

In this article, you will learn how to represent an algorithm using a pseudo code and elements of pseudo codes. Learning a programming language is not necessary to understand pseudo code, but knowing a programming language like C, Pascal, etc. help you understand the pseudo codes better.

The algorithm has two part – heading and the body. See the table below for more information.

HeadingAlgorithm <Name>(<parameter-list>)has the name of the procedure and parameters
Body{ }two braces indicates block of statements
Head and Body of an Algorithm


Algorithm Find_Max( A[n])

// A[n] is the list of unsorted numbers from which
// we need to  find Max value.
        max := 0;
        for i := i to n do
           if max  >= A[i] then
             max := A[i];

The above is sample algorithm to find max value from a list of numbers. The algorithm is written in pseudo code and contains lot of elements with their own notations.

See the table below to understand each notation because you need them for writing algorithms.

Element NameNotationDescription
Comments//start with // till the end of line.
Block{ }indicate a block of statements.
Identifierdummy-variablestarts with a letter, variable data type is not defined.
Assignments<var> := <value>assignments are done using := operator
Logical Operatorsand , or , notcan use logical operators in expressions.
Relational Operators>, <, <=, >=, !=relational operators are allowed
Single Dimensional ArrayA[j]jth element of single dimensional array
Multi-Dimensional ArrayA[i, j]represents a multidimensional array, (i, j) th element.
While loopwhile <condition > do {
a while loop structure
For loopfor var:= value 1 to value 2 step do {
a for loop structure
Conditional statement  if – thenif <condition> then <statement>if  block of statements
Conditional statement if – then – elseif <condition> then <statement> else <statement>if – else block of statements
Inputreadcommand to read input values
Outputwritecommand to write output values
Nodenode = record {
data type 1 data1;
data type 2 data2;

node *link;

A compound data type make of other data types
Codes used in Algorithms

Please support us by disabling your adblocker or whitelist this site from your adblocker. Thanks!

turn of adblocker imag