Home » Creating, Compiling, Linking & Executing ‘C++’ Program

Creating, Compiling, Linking & Executing ‘C++’ Program

Creating ‘C++’ program:

A simple C++ program are shown below:

// Name of program.
#include<iostream.h>
void main()
{
cout << “This is my first program.”;
}

Saving ‘C++’ program:

You can save the C++ program by using .cpp extension.
For example, first.cpp  here first is the name of the program with .cpp file extension.

Compiling ‘C++’ program:

You can compile the your program i.e. first.cpp by pressing the Alt and F9 keys from the keyboards.

If there is no syntax error in the source code i.e. first.cpp program, then the resulting window show- Warning: 0, Errors: 0 and finally Success: Press any key. This compilation process creates an object file of the first.cpp program, which has extension .obj i.e. first.obj.

Linking Object file:

To link your object files, select Link option from Compile menu. The .obj file will be combined with the one or more binary files. The result is an executable file with extension .exe i.e. first.exe.

Executing ‘C++’ program:

You can execute or run the your program i.e. first.cpp by pressing the Ctrl and F9 keys from the keyboards. The result will be displayed on the screen.


Leave a comment

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