Information Technology

Create, edit, compile, link and execute a C program

A process to create, edit, compile, link and execute a C program is as follows:

  • Creating and Editing a C Program
  • Saving a C Program
  • Compiling a C Program
  • Linking a C Program
  • Executing a C Program

Creating and Editing a C Program

The process of writing C program is known as editing. This process includes writing modifying and deleting program statements. The part of turbo C++ IDE that is used to write C programs is called edit window. A new edit window can be opened by selecting File>New option from menu bar. The edit window appears as follows:

Creating and Editing a C Program

The edit window has a double-lined border. The cursor blinks in the window. The position of the cursor indicates the starting point to write a program. The user can expand the window by checking the arrow in the upper right corner. The user can also select Window>Zoom to expand the window. The vertical and horizontal scrollbars are used to navigate through the program.

Saving a C Program

The process of storing the program on disk is known as saving. A program should be saved on disk to be used repeatedly. C  programs are saved with .c extension.

Example:

For example, a program can be saved like program .c. The following procedure is used to save a C program:

Saving a C Program

  1. Select File>Save OR press F2 key. The Save File As dialog box will appear. The default name NONAMEOO.CPP appears in the dialog box.
  2. Enter the file name.
  3. Enter the path to save file. The default location to save programs is BIN directory.
  4. Click OK. The program will be saved at specified location with specified name.

Compiling a C Program

The process of converting source program into object program is known as compiling. The program saved with .c extension contains the statement of C language. It is known as source program. The source program cannot be executed by computer directly. A compiler converts the source program into object program and saves it in a separate file. The object program is saved with .obj extension.

The source program cannot be compiled if it contains any syntax error. The compiler generates error message to describe the cause of error. All errors must be removed to successfully compile a source program.

The following procedure is used to compile a C program:

    • Select Compile > Compile OR press ALT+F9 key. The program will be translated into object program if it contains no error. The compiler will generate error message if the program contains any error.

Linking a C Program

The process of linking library files with object program is known as linking. These files are used to perform different tasks such as input/output. A library file must be linked with the object file before execution of program. A program that combines the object program with additional library files is known as linker. It is part of C++ compiler.

The linker generates error message if the library file does not exist. A new file is created with .exe extension if the process of linking is successful. This file is known as executable file and can be executed by the computer directly. The linker can be started in Turbo C++ by selecting compiler > Link from the menu bar.

Executing a C Program

The process of running an executable file is known as executing. The C++ program can be executed after compiling  and linking. The program must be loaded into the memory to execute. A program that places an executable file in the memory is known as Loader. The program can be loaded in the memory by selecting Run>Run from menu bar or pressing CTRL+F9.

The screen flickers for some time when a program is executed. The output screen displays the output of the program and disappears. The user can display the output screen by selecting Window > User Screen or pressing ALT+F5.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button