An algorithm is a finite set of sequence to solve a class of problems. This may be defined as a sequence of instructions designed in such a way that if the instructions are executed in the specified sequence, the desired result will be obtained.

**PROPERTIES OF ALGORITHM**

- An algorithm may take some input that should generate some output.
- Each algorithm should be terminated after a finite number of steps and finite amount of time.
- Each step should be definite, clear and non ambiguous.
- One or more instructions should not be repeated infinitely. This ensures that the algorithm will ultimately terminate. This ensures that the algorithm will ultimately terminate.
- The steps of an algorithm should be basic and primitive enough for a computer to understand and how is to be done should be specified.
- The steps of an algorithm should be complete.

**EXAMPLES OF ALGORITHM**

Let us start with the easiest example.

#### Algorithm to Add two Numbers:

(Add two numbers) variable declaration A, B as real are inputs here and C as real is to store output.

Step1: Start

Step2: Read: A, B.

Step3: Calculate: C = A + B.

Step4: Print: C.

Step5: Exit

#### Flowchart to Add two Numbers:

#### Algorithm to solve Quadratic Equation:

The solution of the quadratic equation ax^{2}+bx+c = 0 where a ≠ 0, are given by the quadratic formula x = { -b + (b^{2} – 4ac)^{1\2} } / 2a and x = { -b – (b^{2} – 4ac)^{1/2} }./ 2a.

Here D = b^{2} – 4ac is called as the discriminant of the equation. The nature of the roots can be as:

- If D is negative then the roots are imaginary.
- If D is positive then the roots are real and unequal.
- If D is zero then the roots are real and equal.

(Quadratic equation) Coefficients a, b and c of a quadratic equation are taken as input and real solutions are produced as output, if any.

^{2}– 4ac.

^{1/2}} / 2a

^{1/2}} / 2a .

#### Quadratic Equation Flowchart:

#### Algorithm to Find Largest Element in an Array:

(Largest element in an Array) An array DATA having N numeric value is given. This algorithm finds the location LOC and the value MAX of the largest element of DATA. The variable i is used here as a counter.

#### Prime Number Algorithm:

**PRIME NUMBER: **A number which is divisible by either 1 or by self is called prime number. Examples of prime numbers are 2, 3, 5, 7, and 11 and so on.

**NON PRIME NUMBER:** Those Number which are divisible by 1, by self and by some other numbers too then those numbers are called non prime numbers. Examples of non prime number are 4, 6, 8, 9 and 10 and so on.

(Prime and Non Prime) Let N be any positive integer. This algorithm decides whether the given number N is prime number or non prime number. i is used here as a counter. Flag is variable to store either 1 or 0.