DEVELOPMENT OF ALGORITHM & FLOWCHARTS

DEVELOPMENT OF ALGORITHM & FLOWCHARTS

DEVELOPMENT OF ALGORITHM & FLOWCHARTS

 

DEVELOPMENT OF ALGORITHM & FLOWCHARTS

 

C is a structured, high-level, machine independent language.

Dennis Ritchie invented C in 1972.

 

Importance of C:

  1. It is a robust language.
  2. Programs written in C are efficient and fast.
  3. C is highly portable. This means that C programs written for one computer can be run on another with little or no modification.
  4. C language is well suited for structured programming.
  5. C has ability to extend itself.

 

  • Concept of an algorithm and a flow chart, need and definition :

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

 

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:

  1. Each instruction should be precise and unambiguous.
  2. Each instruction should be executed in a finite time.
  3. One or more instructions should not be repeated infinitely.
  4. After executing the instructions, the desired results are obtained.

 

Example:

Write an algorithm to add two nos.

 

Step1: start

Step2: Read a, b

Step3: sum = a + b

Step4: write sum

Step5: stop

 

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 flowcharting 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.


  • Symbols Used to draw Flow chart:

 

  • Examples of flow chart and algorithm:

1.simple calculator:

Algorithm:

  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

Flowchart:

 

2.Find simple interest:

Algorithm:

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

 

Flowchart:

 

 

 

 

3. Find volume of a circle

Algorithm:

1.     Start

2.     Read r

3.     v = 4/3*(3.14)*(r*r*r)

4.     Write v

5.     Stop

Flowchart:

 

4.Calculate the amount to be paid by a customer.

 

Algorithm:

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

 

Flowchart:

 

5.Check whether given no. is odd or even.

Algorithm:

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

                                  No                                                               Yes

 

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.

 

Download complete material in PDF Format

 

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative