Website For Developers

Compiler of C++



A compiler is a program that translates a code into machine code.
There are alot of free compilers of C++ you can download.
The two most used compilers are Microsoft's Visual C++ and GCC/G++.
But Dev is good for a beginner, so we are using Bloodshed - Dev-C++.
You can use any compiler but for that maybe you need to make a little changing of our examples.
All examples are tested and verified on this compiler.
You can copy and paste these examples on your compilers.


After Download and Installation of Bloodshed - Dev-C++:
Step- 1:
Open the comipler.
Step- 2:
Click on: File > New > Source File
Step- 3:
Copy the code from here and paste in compiler

#include<iostream.h>
#include<conio.h>
using namespace std;
int main() {
   cout<<"Hello World";
   getch();
   return 0;
}

Step-4: Save the file (Ctrl+S) , after that click on: Execute > Compile
Now again click on: Execute > Run
All done, The Output will look like:

Hello World



Explanation of first C++ program

#include<iostream>
#include<conio.h>

The C ++ language defines several headers, which contain either necessary or useful program information.
iostream is use for input and output services.
conio.h is mostly used by MS-DOS compilers to provide console output. But now many compilers don't have this header and do not supply the library functions of conio.h.

using namespace std;

It is used for the namespace for every outside objects, variables, and functions you call in your program.
In this program, if you not use using namespace then you have to use std:: with cout.

int main() {
return 0;
}

main() function is the starting point of execution of each and every program in C++.
Return type of the main() function is integer.
When main() function returns 0 value to operating system then program is terminated.

cout<<"Hello World";

cout is use to print the output on the console.

getch();

getch() is non-standard function of conio.h which is used to read the characters from the screen.
If you are using turbo C/dev C++, than you need to make output console wait for some time. getch() is used for that purpose, the console output will never close until user press any key.
getche() function is also use for the same purpose.