Algorithm for C Programming


A typical programming task can be divided into two phases:

·         Problem solving phase

·         produce an ordered sequence of steps that describe solution of problem
·         this sequence of steps is called an algorithm
·         Implementation phase

·         Implement the program in some programming language

 Algorithm:

 An algorithm is a sequence of statements which is used to solve a problem. While writing algorithm we have to consider statements of different types as given below:
  • Input statements
  • Executable statements
  • Storage statements
  • Output statements
In most of the cases, we are combining Executable and storage statements as we are using assignment statements.

An algorithm should possess the following characteristics: 
  • Each and every instruction should be precise and clear
  • Each instruction should be performed a finite number of times
  • The algorithm should ultimately terminate
  • When the algorithm terminates the desired result should be obtained.
Advantages of Algorithm:
  1. Very easy to write
  2. Easy techniques to understand Logic.
  3. It is a step-wise representation of a solution to a given problem, which makes it easy to understand.
  4. An algorithm uses a definite procedure.
  5. It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge.
  6. Every step in an algorithm has its own logical sequence so it is easy to debug.
  7. By using algorithm, the problem is broken down into smaller pieces or steps hence, it is easier for programmer to convert it into an actual program
Disadvantages of Algorithm:
  1. Writing algorithm takes a long time.
  2. Difficult to show branching and looping in the algorithm.
  3. Big tasks are difficult to put in to algorithm.

No comments:

Post a Comment