Before coding a program, the program should be well conceived and all aspects of the program design should be considered in detail.
Program design is basically concerned with the development of a strategy to be used in writing the program, in order to achieve the solution of a problem. This includes mapping out a solution procedure and the form the program would take. The program design involves the following four stages:
1.Problem analysis.
2.Outlining the program structure.
3.Algorithm development.
4.Selection of control structures.
Problem Analysis
Before we think of a solution procedure to the problem, we must fully understand the nature of the problem and what we want the program to do.
Without the comprehension and definition of the problem at hand, program design might turn into a hit or miss approach.
Outlining the Program Structure
Once we have decided what we want and what we have, then the next step is to decide how to do it.
C as a structured language lends itself to a top down approach.
Top down means decomposing of the solution procedure into tasks that form a hierarchical structure, as shown in Fig.
The essence of the top down design is to cut the whole problem into a number of independent constituent tasks, and then to cut the tasks into smaller subtasks, and so on, until they are small enough to be grasped mentally and to be coded easily.
Algorithm Development
After we have decided a solution procedure and an overall outline of the program, the next step is to work a out a detailed definite, step by step procedure, known as algorithm for each function.
The most common method of describing an algorithm is through the use of flowcharts.
The other method is to write what is known as pseudocode.
The flow chart presents the algorithm pictorially, while the pseudocode describe the solution steps in a logical order.
Either method involves concepts of logic and creativity.
Control Structures – Program Design
A complex solution procedure may involve a large number of control statements to direct the flow of execution.
In such situations, indiscriminate use of control statements such as goto may lead to unreadable and comprehensible programs.
It has been demonstrated that any algorithm can be structured, using the three basic control structure, namely, sequence structure, selection structure, and looping structure.