Compilation and Execution Process in C

When we write a C program, the computer cannot directly understand it. So, the code needs to be translated into a language that the computer can run. This is done through a process called compilation.

The overall process from writing the code to seeing the output on screen involves multiple steps.

What is Compilation?

Compilation is the process of converting the human-readable C source code into machine-readable object code. This step is done by a special software called the compiler. If there are no syntax errors in the code, the compiler successfully generates an object file which is used in the next step (linking).

In simple words, compilation translates our C program into a format that the computer can understand.

Steps in Compilation and Execution:

  1. Writing the Code: We write the source code using any text editor and save it with a .c extension (like abc.c).
  2. Preprocessing: Preprocessor handles all #include and #define statements before actual compilation begins.
  3. Compilation: Compiler checks the code for errors and converts it into object code (machine code). The output file is usually abc.obj or abc.o.
  4. Linking: Combines the object code with required libraries (like stdio.h) to create an executable file (abc.exe).
  5. Execution: The executable file is then run by the operating system, and you see the output.

Real-life Analogy:

Imagine you're baking a cake:

  • Writing Code = Writing Recipe
  • Preprocessing = Checking Ingredients
  • Compilation = Mixing Ingredients
  • Linking = Putting in Oven to Bake
  • Execution = Eating the Cake (Final Output)

Compilation Process Summary Table:

Step Description Output
1. Preprocessing Handles macros and header files Expanded source code
2. Compilation Checks for errors and converts code to machine language Object file (.obj / .o)
3. Linking Combines object file with standard libraries Executable file (.exe)
4. Execution Runs the executable file Program Output

Summary:

  • Compilation is the process of converting human-readable C code into machine code.
  • It involves preprocessing, compilation, linking, and execution steps.
  • Each step has its own role in preparing the program to run correctly.

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar