How To Write Hello World Program In C++ Programming Language

 How To Write a Hello World Program In C++ Programming Language

Today in this blog post we are going to cover about the C++ programming language. C++ is a high level programming language, with the help of C++ programming we can build we can build different kind and types of applications. C++ is a high performance, general-purpose programming language, developed by Bjarne stroustrup at AT&T Bell labs in 1979. The C++ programming is basically an enhancement or extension of C programming language.

There are some main features in C++ programming, which are, it is an object-oriented programming language, it uses exception handling, we are going to look at some more important features of C++ language in upcomming sections. For now keep this thing in mind that with the help of C++ programming language we can develop,

1) Desktop Applications.

2) Game Development.

3) Operating Systems.

4) Embedded Systems.

5) Device Drivers.

6) Client-Server Applications.

7) etc.

I hope now you can understand the value and importance of C++ programming language.

In this post we will look at how a C++ program works. We will try make the example as simple as possible for the beginners so they can easily understand the basics of C++. We will write a simple C++ hello world program in C++ programming language which is considered as the very first program in almost every programming language.



A Brief Introduction to the C++ Programming Language

C++ is an object oriented programming language and it is an extension to C programming language. C++ is a general purpose programming language and it is also a case-sensitive language. C++ is very powerful programming language it has features of both low level and high level programming languages, and that is why it is called mid level programming language.


Some important features of C++ programming language

Before diving into how we can write a very first C++ program which is a Hello World program let us look at some important features of C++ programming language.

1) C++ is an object oriented, procedural, and mid level programming language.

2) We can build high level applications with it.

3) We can also build cross-platform application with it.

4) It is compatible with multiple platforms.

5) etc.


Simple coding example of Hello World program in C++ programming language


#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	cout << "Hello World";
	_getch();
}

Above is an example of a simple Hello World program in C++ programming language. Now let us look at the code, and I will take you through this code and explain each line of code step by step in an easy way so that beginners can understand it very easily.


Explanation of C++ code

In the first two lines we used #include directive to include or give the reference of header files which are iostream and conio.h.

#include<iostream>
#include<conio.h>

For now, consider these files as documents that we included in our C++ program, due to which we can use some functions and objects that are defined in these files.

These functions and objects include _getch() and cout which are defined in iostream and conio.h files.

cout << "Hello World";
_getch();

In the third line, we used the using namespace std. This line indicates that we are using a namespace in this code which is named as std.

using namespace std;

If we don't use or include std at the start of the code, then with every cout statement we have to write it like std::cout << "Hello World";

std::cout << "Hello World";

After that, we used the void main() function, which is the main part of our program. A C++ compiler always looks for this function with the name main(). This is the entry point for our C++ program.

void main()
{
	
}

cout<<"Hello world" is used to print a Hello World message to the console screen. With the help of the cout object, we can display output to the console screen.

And at last we used the _getch() function that holds the console screen and does not let it disappear after the successful execution of our program. So this is a simple C++ coding example which shows how we can write simple hello world program in C++ programming language.

Congratulations!, like always we have successfully implemented the first C++ Hello World program.

Comments

Popular posts from this blog

How to Download and Install Microsoft visual studio community 2022 for free

Hello World Program In C Programming Language

How to add two numbers in C programming language