Development of Algorithm & Flowcharts

      Comments Off on Development of Algorithm & Flowcharts

Development of Algorithm & Flowcharts

Development of Algorithm & Flowcharts

Development of Algorithm & Flowcharts is first step towards learning programming language. Generally you need to develop algorithm/flowchart of some process with step by step procedure. Let’s start!

The main purpose of using an algorithm is to illustrate the flow of data and problem solution logic.

What is Algorithm?

An algorithm is a finite sequence of well-defined steps or operations for solving a problem in a systematic manner. In another words we can say that an algorithm is a step-by-step problem-solving procedure.

An algorithm generally takes some input, carries out a number of effective steps in a finite amount of time, and produces some output.

Rules for writing Algorithm
Each instruction should be precise and unambiguous.
Each instruction should be executed in a finite time.
One or more instructions should not be repeated infinitely.
After executing the instructions, the desired results are obtained.

Algorithm Example 1: Write an algorithm to add two nos.

Step1: start
Step2: Read a, b
Step3: sum = a + b
Step4: write sum
Step5: stop

What is Flow chart?
It is a graphical representation of a program flow or an algorithm of a problem to be solved by a computer.

It is an aid to solve a complex problem easily and efficiently. It shows the detailed view of a program flow.

Rules for drawing flowchart:

  1. Use common statements that are easy to understand for words within flowchart symbols.
  2. Be consistent in using names and variables in the flowchart.
  3. Go from left to right and top to bottom in constructing flowcharts.
  4. Keep the flowchart as simple as possible.
  5. If a new flow charting page is needed, break the flowchart at an input or output point. Use properly labeled connectors to link the flowchart on different pages.

Advantages of drawing a flowchart:

  1. It helps a programmer to get a good visual reference of the structure of a program.
  2. It not only serves as program documentation but also helps as a means to communicate with several programmers, as it is language independent.
  3. It allows a programmer to test alternative solutions to a problem without even coding the program. It is much easier to find and correct logic errors prior to coding.
  4. It serves as a useful reference or a programming aid due to its simple and efficient method of representing the program logic of a problem.

Algorithm Example 2 Simple Calculator:

  1. Start
  2. Read a, b
  3. Compute sum = a + b
  4. Compute sub = a – b
  5. Compute mul = a * b
  6. Compute div = a / b
  7. Compute mod = a % b
  8. Write sum, sub, mul, div, mod

Algorithm Example 3 Find Simple Interest:

  1. Start
  2. Read p, r, n
  3. si = (p*r*n)/100
  4. Write si
  5. Stop

Algorithm Example 4 Find volume of a circle

1.     Start
2.     Read r
3.     v = 4/3*(3.14)*(r*r*r)
4.     Write v
5.     Stop

 Algorithm Example 5 Calculate the amount to be paid by a customer.

  1. Start
  2. Read cr, pr, cpu
  3. Compute uc = cr-pr
  4. Compute total_bill = uc*cpu
  5. Write total_bill
  6. Stop

 Algorithm Example 6 Check whether given no. is odd or even.

  1. Start
  2. Read n
  3. Is (n%2 = = 0)? Goto step 5
  4. Write no is odd
  5. Write no is even
  6. Stop

 Difference between Flowchart and Algorithm

Algorithm Flowchart
An algorithm is a finite sequence of well-defined steps or operations for solving a problem in a systematic manner. It is graphical representation of algorithm
It is easy to write and difficult to understand than flowchart It is difficult to draw and easy to understand than algorithm
It does not follow strict rules It use standard symbols for drawing.

Hope you have understand the concept of FlowChart and Algorithm, Once you understand the complete concept, You should start with development of Program for the development of logic. In case if you have any doubts and you want to refer Algorithm and FlowChart tutorial again you can download offline version here.

If you like my article, Please share with your friends on Facebook, WhatsApp, Twitter, etc. Thanks in Advance.