Program written in high level language must be translated into machine language for execution. So after writing C program it must go through various stages to become executable file.
Creating and executing C program requires at least four steps, now we will discuss these steps.
This steps for creating and running programs are writing/editing, compiling, linking and execution . This can be viewed diagrammatically.
1. Creating the program
2. Compiling the program
3. Linking the program with function
4. Executing program.
Creating the program :
First of all, we need to create a C program for execution. We use an editor to create or edit source program (also know as source code).C Program file has extension. C ( for example : myprogram.c,hello.etc)
Compiler :
After creating or editing source code we need to compile it by using compiler . If compiler dose not detect any errors in the program, then it produces object files. Object file has extension . OBJ ( for examples : myprogram.obj, hello.obj, etc ). If compiler detects error in the program, then we need to return to step 1 to make correction in source code.
Detail Compilation process in c
Link :
Object files are not executable file so in order to make executable file we use linker . If no errors occur, linker produces executable file having extension. EXE ( for example : myprogram.exe, hello.exe ect )
Execute :
After obtaining executing file we can run this just like other applications. We need to test to determine whether it works properly or not . If application dose not work properly we need to return to step 1.
Important points of Creating and Running C program
- C program file (source file) must save with .c extension.
- The compiler converts complete program at a time from high level language to low level language.
- Input to the compiler is .c file and output form the compiler is .exe file but it also generate .obj file in this process.
- The compiler converts the file only if there are no errors in this source code.
- CPU places the result in User screen window.
0 Comments