Execution Flow of C Program

C Language Program goes through a couple of execution processes before running, which converts the source code into machine understandable binary code. In this tutorial, we will discuss this process in detail.

C Program Execution Flow

1. Preprocessor

Source code written in C Language is used as an input for preprocessor. Preprocessor converts all the directives into their respective values. It generates an expanded source code by attaching all the header files with the source code.

2. Compiler

Expanded Source Code is sent to compiler. Compiler reads the expanded source code and converts it to assembly level code after compiling the whole program.

3. Assembler

Output of Compiler (Assembly Code) is sent to assembler. In this stage, assembler converts the assembly code into Object Code, which is quite similar to machine code.

4. Linker

Linker takes the object code, generated by assember and link it with other binaries. These binaries helps to execute the program on machine. After linking,Linker generates the final Machine code which is machine understandable and executed directly on target machine.

5. Loader

Loader is responsible for loading the binary code into system's primary memory (RAM) and its execution. After completing the execution, the output is shown on console.