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
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.
Suggested for you
Nested for loop in C++ language
Nested for loop in Java language
Nested for loop in Python language
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…