A compiler converts source code into assembly code.
Source code is the high level language we write. High level language is C, C++, JAVA.
Assembly code is a low level instruction that can be easily understood by a machine.
Therefore, the job of the compiler is to convert the high level language we write into low level instructions that the machine can understand.
Also, it is the compiler's job to let us know if there is any syntax error in the source code.
Now let's go step-by-step about C program compilation:
First we have to write a C program and save it. I want to give the name of this program as hello. Then we have to save it by giving hello.c.
Here .c is the file extension.
We now compile the program.
If there is no error in the program we have written, the compiler will convert the program we have written into an object program.
After this important work takes place. That is the linking process. We will provide header file at the beginning of C program.
This header file contains a lot of pre-defined functions.
With the help of this linking process, the pre-defined function in the header file will be linked to our C program. If these are done correctly, the object program is converted into an executable program.
hello.exe
This exe file is run and we see the output.