Hello World Program

This is very simple program. You can write it easily. The exact code for this program is given below. 

#include <iostream>
using namespace std;
void main()
{
  cout<<"Hello World!"<<endl;
  system ("pause");
}

Explanation:

In the first line#include <iostream>  it is c++ built in library. This library provides some functions that are very useful. You will understand it gradually, when you will study functions and classes in c++. As a beginner, it is enough for you to remember that it is a built in library and you have to include it in every code or program.

The second line using namespace std; make it easy for you to use input stream cin>> , output streams cout<< , and other function like endl easily. If you do not use it or if you want to skip it then you will have to write std::cout<< instead of only cout<< , std::cin>> instead of cin>> and std::endl instead of endl.

The third line void main() means the main code has been started. Here, void shows that this main code return nothing, we will further study it when we will start functions in c++.

The forth line just contain a starting curly bracket {. The code is written after this starting curly bracket.

The fifth line cout<<"Hello World!"<<endl; is a code to execute Hello World on the console. Here, cout<< is a command to print. The thing we want to print is placed with in the inverted commas " ". Similarly, <<endl is code for end of line. It ends the line and start a new line. In c++, it is compulsory to write semicolon ; to tell the compiler that the line of code has been ended.

The sixth line system ("pause"); is a code to pause the system. It basically, stop the system. If we do not write it, the Hello World! will appear on the console for just a instant and the code will be executed. It enable the code to keep showing the program until the user press any button to get out of the code.

The seventh line is just the ending curly bracket }. It shows that our code is end.

Comments

Popular posts from this blog

Community Detection Algorithm (Leiden Algorithm in Python)

Stack and Queues

How To Earn Money Online