Bcaguru

The Way to Creat and Run ‘C’ Program

Generally as we all know, the programs are being created by using programming languages like C, C++, Java etc., and these all are written in high level language like English.

                               But, computer cannot understand the high level language. A computer can understand only low level language. So, the program written in high level language needs to be converted into low level language to make it understandable and easy for the computer. This conversion is performed by using 2 performer or converters, either Interpreter or Compiler.

Popular programming languages like C, C++, Java etc., properly use compiler for the conversion of high level language instructions into low level language instructions. Compiler is also a program that can converts high level language instructions into low level language instructions. Generally, compiler performs two things, first it verifies the program errors, if errors has founded, it returns list of errors otherwise it converts the complete code into low level language.

To build and execute C programs in Windows Operating System, we need to install Turbo C software. The following steps are used to create and execute C programs in Windows OS…

Step 1: Creating Source Code

Source code is a file with C programming instructions in high level language. To create source code, we use any text editor to write the program instructions. The instructions written in the source code must follow the C programming language rules. The following steps are used to create source code file in Windows OS…

  1. Click on Start button
  2. Select Run
  3. Type cmd and press Enter
  4. Type cd c:\TC\bin in the command prompt and press Enter
  5. Type TC press Enter
  6. Click on File -> New in C Editor window
  7. Type the program
  8. Save it as FileName.c (Use shortcut key F2 to save)

Step 2: Compile Source Code (Alt + F9)

Compilation is the process of converting high level language instructions into low level language instructions. We use the shortcut key Alt + F9 to compile a C program in Turbo C.

Compilation is the process of converting high level language instructions into low level language instructions.

When we press Alt + F9, the source file is automatically going to be submitted to the Compiler. On receiving a source file, the compiler first checks for the Errors. If there are any Errors then compiler returns List of Errors, if there are no errors then the source code is converted into object code and stores it as file with .obj extension. Then the object code is given to the Linker. The Linker combines both the object code and specified header file code and generates an Executable file with .exe extension.

Step 3: Executing / Running Executable File (Ctrl + F9)

After completing compilation successfully, an executable file is created with .exe extension. The processor can understand this .exe file content so that it can perform the task specified in the source file.

We use a shortcut key Ctrl + F9 to run a C program. Whenever we press Ctrl + F9, the .exe file is submitted to the CPU. On receiving .exe file, CPU performs the task according to the instruction written in the file. The result generated from the execution is placed in a window called User Screen.

Step 4: Check The Result (Alt + F5)

After running the program, the result is placed into User Screen. Just we need to open the User Screen to check the result of the program execution. We use the shortcut key Alt + F5 to open the User Screen and check the result.

Process for the Execution of  ‘C’ Program

When we execute a C program it undergoes with following process…

  • The file which contains c program instructions in high level language is called source code. Every c program source file is saved with .c extension.
  • for example:- Sample.c.
  • Whenever we press Alt + F9 the source file is submitted to the compiler. Compiler checks for the errors, if there are any errors, it returns list of errors, otherwise generates object code in a file with name Sample.obj and submit it to the linker. Linker combines the code from specified header file into object file and generates executable file as Sample.exe. With this compilation process completes.
  • Now, we need to Run the executable file (Sample.exe). To run a program we press Ctrl + F9. When we press Ctrl + F9 the executable file is submitted to the CPU. Then CPU performs the task according to the instructions written in that program and place the result into UserScreen.

    Then we press Alt + F5 to open UserScreen and can check the result of the program.

Important Points

  1. C program file (Source file) must be saved with .c extension.
  2. Compiler changes complete program at a time from high level language code to low level language code.
  3. Input to the compiler is .c file and output from the compiler is .exe file, but it also generates .obj file in this process.
  4. Compiler converts the file only if there are no errors in the source code.
  5. CPU places the result in User Screen window.

Overall Process { 4 better understanding}

  1. Type or create the program in C editor and must save with .c extension (Press F2 to save).
  2. Press Alt + F9 for compilation of the program.
  3. If there are any errors, correct the errors and  again compile the program  (press Aly+F9).
  4. If there are no errors, then press Ctrl + F9 to execute / run the program.
  5. Press Alt + F5 to open UserScreen and check the result.

Leave a Reply

Close Menu
error: Content is protected !!