What is Recursion in C++ programming language

Image
 What is Recursion in C++ programming language Today in this blog post we will cover the concept of Recursion in C++ programming language for  beginners. So what is Recursion? And what is the use of Recursion in programming languages? We will cover the answer of these questions shortly. For now let us look at the basic introduction of Recursion. Recursion is a concept in which the function calls itself with in its own body, and breaks the complex problems into smaller and more manageable parts. So the first question was what is recursion? Basically Recursion is a method or technique which is used in programming languages and in this method the function calls itself. It means the function is called with in its own body. We will cover this concept with simple programming example which will make the concept of recursion crystal clear to the audience. The Second question was what is the use of Recursion in programming languages? Recursion simply breaks down complex problems or pro...

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

 How To Write a Hello World Program In 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.

Hello World program in C++ programming language




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.


Code Description

In the first two lines we used #include directive to include or give the reference of header files which are iostream and 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.

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.

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";

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.

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.

Congratulations, as always, we have implemented our first C++ program successfully.













Comments

Popular posts from this blog

What is Recursion in C++ programming language

Call by value and call by reference in C++ programming language

Nested Loops In C++ Programming Language