Saturday, 1 December 2018

Creating, Executing and Running a C Program

Execution of a program written in C involves a series of steps these are
i) Creation a program
ii) Compiling the program
iii) Linking the program
iv) Executing a program

i) Creating the program: The programming process starts with creating a source file that consists of the statements of the program written in C language. This source file usually contains ASCII characters and can be produced with a text editor, such as Windows notepad, or in an Integrated Design Environment. Create a text file with its name editing with a ‘C’ extension and type a C programming that file.

In case of Turbo C package, the program can be typed using built-in editor. If the operating system is UNIX, the program can be typed using EDI or Vi text editor.

ii) Compiling the program:The source file is then processed by a special program called a compiler. The compiler translates the source code into an object code. The object code contains the machine instructions for the CPU and calls to the operating system application programming interface (API)
The compilation command under UNIX is $cc file name.

Turbo C compiler is under friendly and provides integrated program development environment. Thus compilation can be done by selecting environment. Thus compilation can be done by selecting appropriate menu options.

The translation is done after examining each instruction for its correctness, if everything is alright the composition proceeds silently and the translated program is stored an another file with the name filename. Obj.

iii) Linking the program: Linking is the process of putting together other program files and functions that are required by the program.

For example, if the program is using sqrt () function, then the objet code of this function should be brought from the math library of the system and linked to the main program.

The compiled and linked program is called the executable code, and stored automatically filename, exe or in UNIX files named a. out.

iv) Executing a program : In unix operating system the program can be executed with the executable file a. out, by typing a. out at system prompt$

In Turbo C environment, the RUN option will do the compilation and executing of a program.
During execution, the program may request for some data to be entered sometimes, the program does not produce the desired results. Then it is necessary to correct the source program (or) the data. In case the source program is modified, the entire process of compiling and executing the program should be repeated.


Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

Computer Basics


C Programming


Java Tutorial


Data Structures


MS Office


Database Management