How does a C program executes?

CServer Side ProgrammingProgramming

Here we will see how the C programs are executed in a system. This is basically the compilation process of a C program.

The following diagram will show how a C Source Code can be executed.

In the above diagram there are different steps −

C Code − This is the code that you have written. This code is sent to the Preprocessors section.

Preprocessing − In this section the preprocessor files are attached with our code. We have use different header files like stdio.h, math.h etc. These files are attached with the C Source code and the final C Source generates. (‘#include’, ‘#define’ These are Preprocessor Directives.)

Compiler − After generating the preprocessed source code, it moves to the compiler and the compiler generates the assembly level code after compiling the whole program.

Assembler − This part takes the assembly level language from compiler and generates the Object code, this code is quite similar to the machine code (set of binary digits).

Linker − Linker is another important part of the compilation process. It takes the object code and link it with other library files, these library files are not the part of our code, but it helps to execute the total program. After linking the Linker generates the final Machine code which is ready to execute.

Loader − A program, will not be executed until it is not loaded in to Primary memory. Loader helps to load the machine code to RAM and helps to execute it. While executing the program is named as Process. So process is (Program in execution).

Published on 26-Apr-2019 12:55:23