C++ Basic

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.

Hello world

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.

 

Suggested for you

Hello world in Java

Hello world in C language

Hello world in Python

Hello world program in Python programming language
Introduction of Cpp programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago