Expt 2
Expt 2
ALGORITHMS
Algorithm and flowchart are the powerful tools for learning programming. An
algorithm is a step-by-step analysis of the process, while a flowchart explains
the steps of a program in a graphical way. Algorithms and flowcharts help to
clarify all the steps for solving the problem.
ALGORITHM:
A software engineer commonly uses an algorithm for planning and solving the
problems. An algorithm is a sequence of steps to solve a particular problem or
it is an ordered set of unambiguous steps that produces a result and terminates
in a finite time.
1. Sequence: In the sequence structure, statements are placed one after the
other and the execution takes place starting from up to down.
2. Branching (Selection): In branch control, there is a condition and
according to a condition, a decision of either TRUE or FALSE is achieved.
In the case of TRUE, one of the two branches is explored; but in the case
of FALSE condition, the other alternative is taken. Generally, the ‘IF-THEN’
is used to represent branch control.
3. Loop (Repetition): The Loop or Repetition allows a statement(s) to be
executed repeatedly based on certain loop condition e.g. WHILE, FOR
loops.
ADVANTAGES OF ALGORITHM
▪ It is a step-wise representation of a solution to a given problem, which
makes it easy to understand.
▪ An algorithm uses a definite procedure.
▪ It is not dependent on any programming language, so it is easy to
understand for anyone even without programming knowledge.
▪ Every step in an algorithm has its own logical sequence so it is easy to
debug.