C++ Hello world program explanation
In this tutorial, we will learn about the simple concept in C++ Hello world program.
We start the C++ tutorial series with one of the simplest programs. This is a program that is easy to understand for beginners learning about c++ language. This program is called the Hello world program. When we execute the program, the message “hello world” is displayed on the screen.
This program contains all of the basic components of every C++ programs
- Header file
- Namespace
- Main function
- Print statement
- Return statement
We will execute the C++ codes using code:: block ( How to Download and Install) IDE
Out put
Hello world
Here, we try to understand every line in the C++ program
1. #include <iostream> – This is the header file in C++ Language. This header file starts with cash (#)symbol as used by the compilers pre-processor. That means basic standed input-output library files are included in this header file that is called as the preprocessor.
2. int main() – This is the main method in C++ programming language. It has two components. One of the component is int.
– int – In this case, int is called a return type
– main() – Every C++ program must have a main() function. The main function is the starting point of every program. That means all the C++ program start their execution here. The word “main” is followed by pair of round brackets to be able to pass parameter in possible time.
{} – Two curly brackets. One indicates the starting point of function and the other indicates the ending point the function- This area is known as body of the function.
count<<“Hello world”; – This is a statement in c++, which displays “hello world” on the screen. count 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 the function and indicate the ending point of the function.
Every statement must end in semicolon in C++ language.
Hello world program using class in C++
Out put
Hello world
Related post
Hello world in java