C++

C++ Hello world program explanation

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

Program

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++

Program

Out put

Hello world

Related post

Hello world in java

Hello world in C

Hello world in Python

 

Karmehavannan

Recent Posts

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.