Algorithm and Flowchart-Introduction

Program Design Tools

Computers are problem solving devices and it is an electronic programmable machines that requires a set of instructions to perform tasks. To facilitate a computer to solve problems effectively, clear and concise instructions must be provided to it.  A programmer must provide clear instruction to perform task and he must have a plan to solve particular problem using programming tools like algorithm, flowchart and pseudo code.

Algorithm

An algorithm is the step wise logical instructions written in any human understandable language to solve particular problem in a finite amount of time. It is written in simple English language.

Steps used to develop algorithm are:

  1. The problem has to understood by the programmer.
  2. The expected output has to be identified.
  3. The logic that will produce the required output from the input has to be developed.
  4. The algorithm should be tested for accuracy for a given set of input data.
  5. The steps are repeated till the desired result is produced.

Characteristics of Algorithm

  1. All the instructions of algorithm should be simple.
  2. The logic of each steps must be clear.
  3. There should be finite number of steps for solving problems.
Flowchart

Flowchart is a pictorial representation of stepwise solution of a problem. It helps programmer in developing the program logic and serve as documentation for future reference. It uses different boxes linked by the arrows. The process of drawing flowchart is flowcharting.

How to draw flowchart?

  1. It should be neat and clean.
  2. The flow of procedure direction normally needs to keep from left to right or top to bottom.
  3. There must be only one entry and end point.
  4. Only one flow line should come out from a processing symbol.

Advantages

  1. Flowchart helps programmer to explain the logic of a program to other easily.
  2. Flowchart provides documentation support.
  3. Flowchart is helpful in detecting and removing bugs in a program in s systematic manner.
  4. With the reference of Flowchart programmer can  write a program and correspond the program.   

Disadvantages

  1. Flowcharts are time consuming and laborious to draw with proper symbols.
  2. The complicated logic of a program are not easy to represent.
Flowchart Sequence

Sequence Structure

It is a series of actions performed in sequential order.

Algorithm:

STEP 1: Start

STEP 2: Accept the first number a.

STEP 3: Accept the second number b.

STEP 4: Add a and b , and store in SUM.

STEP 5: Display the value of SUM.

STEP 6. Stop.

Flowchart:

flowchart

Decision Structure

In this structure , one of two possible actions are performed, depending on a condition provided. A new symbol diamond represents Yes / No questions. If its Yes then program flow follow one path and if its No then program flow follow another path.

Algorithm

STEP 1: Start

STEP 2: Read Two numbers a and b.

STEP 3: Compare a and b.

If a is greater than b then print a otherwise print b.

STEP 4: Stop

Flowchart:

decision

Repetition Structure

It represents part of the program that repeat for a certain number of times, It also uses diamond symbol for specifying condition. Repetition structure tests the condition and if the condition is true, it performs the action, it repeats until the condition is false.

Algorithm

STEP 1: Start.

STEP 2: Initialize the variable count to one.

STEP 3: Display the variable count by one.

STEP 4: Increase variable count by one.

STEP 5: Check whether count variable exceeds 10.

If Yes, Go to Step 3, If No Go to step 6

STEP 6: Stop

Flowchart:

repetition

Pseudocode

It is an artificial and informal language that helps programmers to develop  algorithms. It is an outline of a program written in a form that can easily be converted into real programming statements. It cannot be compiled or executed and there are no real syntax.