Let us now look at C++ Hello World Code: Step 1) On configuration page. Select create the cache now option.
You should see a screen something like this
In some computers and operating systems, it asks whether to include all the libraries. If the option is selected, it will install all the libraries. Step 2) Create a new source file. Once the program opens, you need to create a new source file, so you can start writing your first C++ program. To do this select File > New > Source File. The path is shown in the figure below.
This will open an area where you be able to type out your code. Step 3) Now you can write the C++ code. After that you can write the C++ code as shown in the image below:
C++ Code Example: Step 4) Compile your code. In this step, Click on Execute->compile & run
Step 5) Save the file. After saving you should see a black screen outputting “Hello World.”
Output
Your First Program: C++ “Hello World!” Explanation
C++ is a compiled language. The source code is compiled into object files. Object files are then combined by a linker creating an executable program. A production C++ consists of many source code files (usually called source files).
Curly braces, {}, express grouping in C++. Here, they indicate the start and end of the function body. Every C++ program has exactly one global function named main (). The program starts by executing that function. An int value is returned by main (), which it passes to the system.’ If no value is returned, then the system will receive a value 0 thus indicating successful completion. A nonzero value from the main () function indicates failure.
Explanation of C++ Hello World Program Code
Code line 1: The first line is #include
Summary
- The “Hello World” program is the first step towards learning any programming language.
- After installing a C++ compiler and a Text Editor of your choice, you can go ahead and execute your first basic C++ program.
- The first line is #include . It instructs the compiler to include the standard stream I/O library.
- int main(). This is the main function of the program. The operator « writes its second argument onto its first. Return 0; is the last command in the main function which is the return statement.
- Cout is a stream that outputs the stream specified.