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.

 

Similar post

Introduction of Java language

Introduction of C++ language

Introduction of C language

Suggested for you

Hello world in Java

Hello world in C++

Hello world in Python

Hello world in C#

 

 

for loop in Java

while loop in Java

for loop in C language

while loop in C language

while loop in cpp language

For loop in Cpp language

Nested for loop in C++ language

Nested for loop in Java language

Nested for  loop in C language

Nested for loop in Python language

 

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

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago