C Increment Operator Prefix Increment Operator Post Increment Operator

C Program Execution

This tutorial is yet another tutorial of the series. In this tutorial, we will learn about the different stages of execution of a C program. We will also learn how we can perform these stages of execution of any c program in the Unix environment as well as in the Dos environment.

C program Execution Stages

Each C program has to go through 3 stages before its final execution. These three stages are listed below.

  1. Program creation.
  2. Program compilation.
  3. Program execution.

Further, if we talk about the environment of a C program execution. A c program is written and executed mainly in two environments. These two environments are the UNIX and DOS Environment. How a program is executed into these environments is explain below with appropriate commands.

UNIX Environment

The Unix OS by default is always provided a command-line C compiler. This command-line C compiler is either called CC or GCC.

Program creation

In the UNIX environment, the c program file can be created with the help of ‘vi’ editors. The command $vi filename.c is used to create the program file. Here the $ symbol specifies the UNIX prompt. In this environment, the program file can be saved by pressing ESC+SHIFT+zz.

Program compilation

After program creation or after writing the program, we have to use the cc editor to compile this program. It can be compiled with the command $cc filename.c. In a special case if the program has a mathematical function then it can be compiled with the command $cc filename.c -1m. After successful compilation without any error or bug, the program is fully ready to execute

Program execution

Now the program can be executed with command $a.out.

MS-DOS Environment

This is the most used environment. In this environment, all three stages of program execution are done through the command line or with IDE. The IDE stands for the “Integrated Development Environment”.

Command Line

Turbo C and Borland C use different command-line compilers. tcc.exe and bcc.exe command-line compilers are used in Turbo C and in Borland C respectively.

Program creation

With the help of any text editor, the program can be written. But the program must always be saved with the .c extension.

Program compilation

After the creation of the C Program file. It will be compiled using the DOS prompt. Just write C:\>tcc followed by the file name (in Turbo C). In Borland C just write C:\>bcc filename. After the successful compilation of the C Program, the executable file is created with the .exe extension.

Program compilation

Once the program file is compiled and saved with no error. It can be executed in this environment by writing C:\>filename.

Leave a Comment

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