# 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:

- It is a robust language.
- Programs written in C are efficient and fast.
- C is highly portable. This means that C programs written for one computer can be run on another with little or no modification.
- C language is well suited for structured programming.
- 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:__

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

__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:__

__ __

- Use common statements that are easy to understand for words within flowchart symbols.
- Be consistent in using names and variables in the flowchart.
- Go from left to right and top to bottom in constructing flowcharts.
- Keep the flowchart as simple as possible.
- 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:__

** **

- It helps a programmer to get a good visual reference of the structure of a program.
- It not only serves as program documentation but also helps as a means to communicate with several programmers, as it is language independent.
- 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.
- 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: **

- Start
- Read a, b
- Compute sum = a + b
- Compute sub = a – b
- Compute mul = a * b
- Compute div = a / b
- Compute mod = a % b
- Write sum, sub, mul, div, mod

**Flowchart:**

## 2.Find simple interest:

**Algorithm:**

- Start
- Read p, r, n
- si = (p*r*n)/100
- Write si
- 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:**

- Start
- Read cr, pr, cpu
- Compute uc = cr-pr
- Compute total_bill = uc*cpu
- Write total_bill
- 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