Compilation Process In C With Examples

Today we are going to learn in detail about what is the compilation process? Why do the compilation process In C.

So, without losing time, let’s first know what is the compilation process in C Language

Compilation Process In C
Compilation Process In C

What is Compilation Process In C

Compilation is a process by which source code is converted into object code. Compilation Process is completed by the compiler. The compiler checks whether the source code has syntactical and structural errors and if the no error in the source code then it convert the source code into object code.

Why do we need a compilation process?

C language is a high level programming language that requires compilation to convert the code written in C language into a machine-understandable language (binary language or 0’s and 1’s).

This work of compilation process is done by the compiler, the compiler converts the code written in C language into machine code so that the machine is able to understand that code easily.

Compilation Process In C

The work of compilation process is completed in four steps.

  1. Pre-processing
  2. Compilation
  3. Assembly
  4. Linking


The work of pre-processing is done by Preprocessor. Source code (the code that we write in the text editor and whose extension is “.c” is the source code)  first passes through the Preprocessor.

Preprocessor takes that source code as input and then removes all comments from that source code.

Preprocessor interprets code starting with #include For example – if #include <stdio.h> header file is mentioned in our code , then Preprocessor replaces the #include <stdio.h> code with the contents of the file ‘stdio.h’. This is called pre-processing. After pre-processing the source code goes to the compiler.


The work of compilation is done by the compiler. The compiler converts the code received from Preprocessor into assembly language, this is called Compilation. Only the assembler can understand the code converted by the compiler. So after compilation, the code goes to the assembler.


After compilation by the compiler, Assembler converts the code into machine code and Creates an object file which is represented by “.obj” in dos and “.o” in Unix operating system.

For Example – If the name of our source file is master.c then the name of that file will be master.obj.


Predefined library functions like – printf(), scanf(), getch(), etc. are used in all the programs we create in C language. The declaration of these Predefined library functions is in the header file and their definition is in library files. These library files are pre-compiled and these library files are stored with ‘.lib’ (or ‘.a’) extension.

In this step of the compilation process, when we use the linker, The linker combines the object code of the library file with the object code of our program and creates a new file called a “.exe” file or an “executable file”.

This executable file is called software and in this way, a program written in C language is prepared as software.



Friends, I hope you have found the answer of your question and you will not have to search about the Compilation process in C Language 

However, if you want any information related to this post or related to programming language, computer science, then comment below I will clear your all doubts.

If you want a complete tutorial of C language, then see here C Language Tutorial. Here you will get all the topics of C Programming Tutorial step by step.

Friends, if you liked this post, then definitely share this post with your friends so that they can get information about the Compilation process in C Language 

To get the information related to Programming Language, Coding, C, C ++, subscribe to our website newsletter. So that you will get information about our upcoming new posts soon.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro