Page 18 - CloudGPT_C6_Flipbook
P. 18
So, to find the meaning of a particular word in a dictionary, you need to follow a set of steps.
Similarly, before writing a program for a given problem, it is important to define a set of
steps which need to be followed to solve the problem successfully. This sequence of the set
of steps is called an algorithm.
Coding fact
The first computer game 'Spacewar' was created in 1961, by MIT programmer Steve Russell
and his team.
ALGORITHM
An algorithm is a set of steps that must be followed to solve a problem.
Characteristics of an algorithm
Each step of an algorithm should be understandable.
An algorithm must have zero or more than zero well-defined input and one or more
than one well-defined output
Algorithms must terminate after a finite number of steps.
Algorithm must be language-independent.
Advantages of an algorithm
Representation of solution of a given problem in a step by step manner.
Follows a definite procedure.
Easy to understand.
Interdisciplinary
Example 1: Write an algorithm to calculate profit and loss.
Concept:
Cost Price (C.P.): The price at which the object is purchased.
Selling Price (S.P.): The price at which the object is sold.
Profit: If the selling price (S.P.) > cost price (C.P.), Profit = S.P. – C.P.
Loss: If the selling price (S.P.) < cost price (C.P.), Loss = C.P. – S.P.
Solution:
Input = Cost price (C.P.) and Selling price (S.P.)
Output = Display profit (P), loss (L) and no profit no loss
Algorithm:
Step 1: Start
16 Premium Edition-VI

