Saturday, 20 June 2020

DESIGNING, DEVELOPING AND RUNNING A COMPLETE 'C' PROGRAM

DESIGNING, DEVELOPING AND RUNNING A COMPLETE 'C' PROGRAM 

                                                DESIGNING A 'C' PROGRAM

The overall program strategy is completely mapped out before the programming actually begins. This permits to concentrate the general program logic, without concerning the syntactic details of each instruction in the source program.

Once the overall program strategy has been clearly understood, the other details of program statements can be considered. This is generally referred to as TOP-DOWNprogramming approach.




                                             CHARACTERISTICS OF A PROGRAM

The characteristics of the program explained below are necessary to write a computer program in any of the programming languages.

A) CLARITY: It refers to the readability of the program with the underlying logic. If the program is clearly written, it is possible to understand without any effort to another programmer to follow.

B) INTEGRITY: It refers to the accuracy of the program. If the calculations are
not performed correctly, all other program enhancements will be meaningless.

C) SIMPLICITY: The clarity and accuracy of the program are usually enhanced by keeping things as simple as possible with the overall program objectives. It is necessary to sacrifice some of the computations efficiently in order to maintain the program structure simple.

D) EFFICIENCY: It refers to the execution speed and efficient memory utilization of the program.

E) MODULARITY: Many programs can be broken down into a series of identifiable sub-programs. It is good programming practice to implement each of the subtasks in a separate module, such modules in ‘C’ language are called functions. The modularity of 'the program design, enhances the accuracy and clarity of the program, then it facilitates future program alterations.

F) GENERALITY: Usually, the program is to be as general as possible, within reasonable limits.

                                                         WRITING A 'C' PROGRAM

Once the program strategy is understood through Algorithm and Flowchart, then the user must have attention to develop a ‘C’ program. At this stage the process of translating each step of the program outline (Algorithm) into one or more equivalent ‘C’ instructions. This is the straight forward activity providing the overall program strategy.

Here the programmer must understand and write source program by arranging the individual declarations and statements in the right manner and Punctuating them correctly.

As in the case of the following features, the user must pay attention to Program strategy. These features will improve the readability of the program and other results of the program.

i) DOCUMENTATION: It refers to the details to describe a program element in the source program.

ii) LOGICAL SEQUENCING OF THE STATEMENT: Sequencing is used to execute statements sequentially one after another. Selection structures are used to execute particular statements depending upon the condition.

iii) STATEMENT CONSTRUCTION: The statement construction is done in the coding stage.

Use the following steps, to write a source program in any high-level language.

1) Write one statement per line.

2) Avoid heavily nested loops.

3) Place parenthesis in arithmetic and logical expression.

4) Use simple conditional tests.

5) Use proper indentation.

                    ENTERING THE PROGRAM INTO THE COMPUTER USING MS-DOS 

After the program coding is done, it must be entered into the computer and then compiled and executed.

Usually in Turbo C or Turbo C++, or Borland C editor, the program is entered in standard ‘C’ editor as shown below by running the ‘tc’ command.

The program is entered into the editor, it should be saved and then compiled and executed. The saving is accomplished by selecting the Save or Save As option from the File menu and then type appropriate program name.

                          COMPILING AND EXECUTING THE PROGRAM IN MS-DOS 

Once the program has been entered, edited and saved. it can be compiled and executed. This can be done by selecting Debug+Run option or press ALT+F9 for compilation and CTRL+F9 for executing.

                                  ENTERING THE PROGRAM USING UNIX 

We know that ‘C’ is the most popular programming language used under " the UNIX system because the UNIX operating system itself is primarily written in ‘C’ language.

                                               COMPILING THE PROGRAM

The compilation is the process of converting the entire high-level language program into machine-understandable form. For compilation, the ‘cc’ command is used.

                                                RUNNING THE PROGRAM 

Once all the external references are satisfied such as compilation, linking 1 and loading, then an external executable object file was created called a.out.


No comments:

Post a Comment