The compilation and execution (running) process of C program follows multiple steps. A brief explanation of each step is given below:
Step 1: Creating Source Code
When we write a program in ‘C’, that
program is called source code. Every c program source file is saved with .c
extension. To create source
code, we use any text editor. The instructions written in the source code must
follow the C programming language rules.
Step 2: Compiling the program
The compilers job is
to translate the instructions in the source file into instructions called executable
code that the operating system can understand and execute. The source code passes through a number of
intermediate stages before it turns into executable code. The
source code is sent to the preprocessors first.
Preprocessor:
Preprocessor
processes the source code before compilation. It
performs some task like removing comments, include header files, expand the
macros etc. The preprocessor generates the expanded
source code. Then the expanded source code is passed to the compiler.
Compiler:
Compiler will compile the program. It first checks the program errors, if errors are found it returns a list of errors. If the compiler reports no error, then it converts source code into the object code and stores it as a file with extension .obj. Then the object code is given to the Linker.Linker:
Linker is another important part of the
compilation process. It takes the object code and links it with required library
files. After linking, the linker generates executable
code with extension .EXE which
is ready to execute. The executable code is sent
to loader
Step 3: Executing / Running the program
Loader:
Whenever we give the command to execute a particular
program, the loader comes into work. Loader loads
the executable file into the main/primary
memory and then it is executed. After execution, output is sent to the
monitor screen of the computer.
The following diagram will show how a C Source Code can be executed.
0 Comments
if you have any doubts plz let me know...