Home >>C Tutorial >C Program Flow

C Program Flow

C Program Flow

There are many steps in execution that are followed by the C program. In order to understand the flow of a C program to the fullest, here is an example of a simple program of C.

File: simple.c

#include <stdio.h>    
int main(){    
printf("Hello there");    
return 0;   
}  

The Execution Flow

Here is the flow chart depicting the flow of the above-mentioned program:

1. The C program (source code) firstly, is sent to the preprocessor. To convert the preprocessor directives into their respective values, the preprocessor is responsible. An expanded source code is generated by the preprocessor.

2. Then the expanded source code is sent to the compiler that compiles the code and converts into the assembly code.

3. The assembly code is then sent to the assembler that assembles the code and converts into the object code. Then, a simple.obj file is generated.

4. The object code is then sent to the linker that links it to the library like header files. In the next step, it is converted into an executable code. Then, a simple.exe file is generated.

5. The executable code is then sent to the loader that loads the code into the memory followed by the execution of the code. The output is then sent to the console, after execution.


No Sidebar ads