Flowcharts & Algorithms
INTRODUCTION:
In this Article, we learn about computer fundamentals. In this article we have
discussed tools which can be used to develop logic of program before writing
any program. Flowcharts & Algorithms are example of such tools , which are
used for development of software in C & C++. These provides convenience in
development of programs.
PROBLEM SOLVING TECHNIQUES:
The problem solving techniques is used for solving of the problem. When any
problem require to solve with help of computer programming language,
computer cannot solve this problem by its own way, it require to follow
following steps or factors.
- Problem definition
- Analysis of problem
- Find out input and output if require
- Choose appropriate tools to solve problem (algorithm or flowchart)
- Choose appropriate control structure for developing program( code design)
- Run and debug the program ( error finding )
- Verify the output as per definition
Let us start first with flowchart, how to develop logic of program.
FLOWCHART:
A Flowchart is graphical or diagrammatical representation of sequence of
any problem to be solved by computer programming language. It is used to
prepare first before writing any program. It is also used to correct and
debug a program flow after coding part is completed. Through flowchart it
is easy to understand the logic and sequence of problem. After drawing
flowchart it becomes easy to write any program. There are various standard
symbols available to represent logic of problem which are:
List of Flowchart Example:
- Draw a flowchart to find sum of two number.
- Draw a flowchart to find area of rectangle.
- Draw a flowchart to find average of three subject marks.
- Draw a flowchart to find maximum number from two numbers.
- Draw a flowchart to find whether given number is Even or Odd.
- Draw a flowchart to find maximum number from three numbers.
- Draw a flowchart to find root of equation: ax2 + bx + c.
- Draw a flowchart to reverse given number.
- Draw a flowchart to find factorial of given number: f= 1 X 2 X 3 X ...... X N.
- Draw a flowchart to find power and base.
- Draw a flowchart to find sum of 10 elements read from user.
- Draw a flowchart to find maximum number from N different number.
- Draw a flowchart to generate fibonacci series upto given term.
ALGORITHM:
An algorithm is a finite sequence of well defined steps or operations
for solving a problem in systematic manner. These are rules for
solving any problems in proper manner. Instruction are written in the
natural language. It is also called step by step solution.
Types of algorithm:
There are various types algorithm techniques exists, according to
types of problem appropriate types of algorithm used.
- divide and conquer
- greedy method
- branch and bound
- recursion
- effectiveness
- Divide and conquer: The divide and conquer technique is used to solve complex problem easily. Complex problems are decomposed into several step, which make problem easy to solve.
- Greedy method: This method is used to solve optimization problem. With several possible solution one best solution is selected with help of this method.
- Branch and bound: when there are several statement or certain part of logic repeated this type of concept is used. A branch and bound algorithm computes a number(bound) at a node to determine whether the node is promising.
- Recursion: when procedure call itself is called recursion.
- Effectiveness: All operations can be carried out in predefined time and sequence.
List of algorithm Example:
- Write an algorithm to find out sum of two numbers.
- Write a algorithm to find out are of square.
- Write an algorithm to find average of three numbers.
- Write an algorithm to find whether given number is positive or negative.
- Write an algorithm to find out minimum number from three input numbers.
- Write an algorithm to find factorial of given number
- Write an algorithm to reverse given number.
- Write an algorithm to solve following series 1! + 2! + 3! + ... +n!
- Write an algorithm to find whether given number is armstrong or not.
- Write an algorithm to find maximum number from n numbers.
- Write an algorithm to generate Fibonacci series up to given term 1 1 2 3 5 8 13.....
- Write an algorithm to store sum of 10 different numbers.
- Write an algorithm to find whether given number is prime or not.
- Write an algorithm to find occurrence of given number from different numbers by using array.
PSEUDO CODE:
It is language or part of language used to convert program into
easy form. It allows the programmer to write logic of flowchart or
algorithm in symbolic form. Pseudo means code refer to set of
instruction written in a programming language. Hence, pseudo code
is a limitation of actual computer instruction without referring
to any specific compiler or programming language.
The pseudo code normally consists of phrases of English language to
describe the logic steps of a programming module. It does not occupy
any space at a time of compiling or assembling.
Pseudo code can be used for following situation.
1. Storage declaration
2. Assignment of any value.
3. Procedure call
4. Input/output
5. Constant value