Hello world program in Cpp programming language
Hello world program in Cpp programming language
In this tutorial we will discuss about Hello world program in Cpp programming language
When we begin to learn the C++ language, usually we write the first step of coding in hello word program.
This program is very simple and easy to understand for beginners. When we write the code and execute using IDE, C++ display the message from hello world on the screen.
Before you write the program, conform that test editor and proper IDE are installed on your system.
Write Hello word program
The program is written on your text editor and save using the correct extension for C++ language(.CPP)
Then compile the program using your compiler(IDE’s for C++ are code block, NetBeans for c/cpp, Eclipse IDE for c/cpp,Div-c++ etc)
Program 1
#include <iostream>//Header file for input output functions using namespace std;//name space int main()//main function { //the starting point of execute the program cout << "Hello world!" << endl; //displays Hello world return 0;//return statements }//End main function
When the above code is executed, it produces the following results:
Hello world!
We divide the above simple program of 5 parts
- Header file
- Name space
- Main function
- Print statement
- Return statement
Header file
C++ language have many header files to performs it’s various functionalities.
Here, #include <iostream> header file starting with # sign for basic stranded input output functionality which is called as pre-processor
Name space std
Standed c++ library is defined in this std name space and avoids names conflict
Main function
– int – In this case, int is called as return type
– main() – Every C++ program must have a main() function. The main function is the starting point of every programs. That means all the C++ program start their execution here. The word main is followed by pairs of round brackets to pass parameter in possible time.
{} – Two curly brackets; One indicates the starting point of function and other indicates ending point the function- This area is known as body of the function.
cout<<“Hello world”; – This is a statement in c++ which is displays “hello word” on screen. It represents the standard output stream in C++
return 0; This is a statement in C++ language. This statement is used to return a value from function and indicates the ending point of the function.
Every statements must end with semicolon in C++ language.
Similar post
Suggested for you
Nested for loop in C++ language
Nested for loop in Java language
Nested for loop in Python language