You are on page 1of 9

BUILDING BLOCKS OF

ALGORITHMS

Submitted by,
Abhisamol.V.M
I.M.SC.Maths(A)
Roll.No:3002
BUILDING BLOCKS OF ALGORITHMS:

The basic building blocks of algorithms are as


follows:

a) Statements

b) State

c)Control flow

d) Functions
1) Statements:
A statement is a single action in a computer.
Statements might include some of the following actions:

i) Input: information given to the program

ii) Processing: perform operations on a given


input

iii) Output: processed result


2) State:
The state of an algorithm at a given
point in its execution is the collection of values
of all variables contained in the algorithm at
that point. The state of an object is the current
status of the object. A transition can occur
from one state to another due to some
processing.
3) Control flow:
The order in which the statements of an algorithm
are executed is called the CONTROL FLOW of the
algorithm. The control flow can follow these three
ways:

a) sequence

b) selection

c) iteration
a)Sequence:
All the instructions are executed one after another.

Example:

Algorithms 1.1

Input: ---
Required Output: A display saying “Good Morning”

step 1: Start

step 2: Print “Good Morning”

step 3: Stop
Algorithm 1.2:

Input: Two numbers a and b.

Required Output: The sum of a and b.

Step 1: Start

Step 2: Read inputs a and b.

Step 3: sum = a + b

Step 4: Print sum

Step 5: Stop
Algorithm 1.3:

Input: Radius r of the circle.

Required Output: Area of the circle

Step 1: Start

Step 2: Read the radius r of the circle

Step 3 : Area = pi x r x r // calculation of area

Step 4: Print Area

Step 5: Stop.

The above algorithms follow sequence execution.


THANK YOU

You might also like