C++ Tutorial

Hi, my name is William. I'm here to teach you one of the most well-known and prestigious computer programming languages in the most efficient manner possible, utilizing both brief and essential theory as well as practical codes and their outputs.

However, I believe there are a few questions we should answer before beginning the course. So, let's start right away by answering some important questions about the programming language "C++."

What is C++?

C++ is a general-purpose computer programming language that has the following primary characteristics:

C++ is a C programming language extension. C++ contains all of the elements of the C language as well as extra features for working with objects, classes, events, and other object-oriented concepts.

C++ influenced many computer programming languages, of which the following is a list of some of the most famous and powerful ones:

including C#, Perl, and many more.

Who Invented C++? | A Quick History

Bjarne Stroustrup created the C++ programming language in 1980 at AT&T Bell Laboratories. He discovered that "C" was lacking in simulations (the technique of representing the real world by a computer program) and decided to extend the language by incorporating some features from Simula 67, his favorite language.

Simula 67 was one of the first object-oriented programming languages. Bjarne Stroustrup originally referred to it as "C with Classes."

Rick Mascitti coined the term "C++." The "++" operator is an increment operator in C++. C++ has evolved to deal with problems encountered by users and through discussions at AT&T since its inception.

The C++ programming language first appeared in 1985. Can you imagine the age of this language?
Because of its age, the language is now very stable, and there is a large community to help you if you start coding in C++ and get stuck somewhere.

The main reason for C++'s success

The main reason why C++ is so successful and well-known is that it uses object-oriented technology, which is the newest and most realistic way to make software.

A brief message for our students

C++'s official website is isocpp.org. If you are only conversant with C++. I mean, if you're a die-hard C++ developer who relies solely on this language, I recommend you keep visiting the official website. As a result, you will receive all announcements regarding news, updates, and much more.

Almost every computer language now has its own official website, not just C++; for example, "HTML" has "html.spec.whatwg.org," "Python" has "python.org," "Java" has "oracle.com/java/java.com," and so on. However, most people, especially beginners, find it difficult to learn the language from the official site; thus, we step in to select the main topics and briefly explain them so that even a beginner learner can grasp the concept.

C++ Environment Setup

I recommend that we start by preparing the environment. So please allow me to assist you in configuring a C++ environment for your system so that you can easily execute C++ code.

I won't recommend installing a code editor like Notepad++ or "Visual Studio Code" and then separately installing the "compiler" for you. Instead, I recommend that you download and install one of the well-known free, open-source, cross-platform IDEs that includes a compiler (GNU GCC Compiler).

So simply search for "CodeBlocks download" and open any relevant page to download and install it. In my case, here's a screenshot of the download window. I included this screenshot for your convenience. This image depicts the approximate download size of a "Code::Blocks IDE."

c++ code blocks download size snap

Install the "Code::Blocks IDE" on your system after downloading it. This is one of the windows you will see while installing. I included this screenshot to demonstrate the space size required by this IDE.

c++ code blocks IDE size snap

After installing "Code::Blocks," launch it. Now, as shown by the red arrow in the following screenshot, click on "Create a new project."

c++ environment setup one

Then, as shown in the screenshot below, click on "Files."

cpp course code block setup

Now select "C/C++ source" and press the "Go" button as shown below:

cpp course setup create a new project

Now another window may appear, in which you must select "Next," and the following windows will appear:

cpp course select cpp while setting up

Select "C++" and then click the "Next" button. Now, click the three dots as shown below, navigate to the folder, type the file name "codescracker.cpp," and then click the "Finish" button. The ".cpp" extension indicates that the file contains C++ source code.

cpp select source file and location

Following the completion of the preceding steps, you will see the following window:

cpp code blocks window after setting

Now enter your C++ source code in the above-mentioned box. As an example:

cpp source code written in code blocks

That is, I have written the following C++ program:

using namespace std;
int main()
   return 0;

To see the output of the above C++ source code, navigate to "Build" and select "Build and run" or directly hit the "F9" key. After building and running the above C++ program, here is a snapshot of the output:

cpp course beginners welcome code example

I used the red arrow to focus your attention solely on the output text.

In a separate article, I defined each and every line of code in the preceding C++ example program. You can find it here: C++ basic syntax.

Now that everything is in place, let's get started on the course.

Comments in C++

Comments are content written within the program to explain specific blocks of code or to aid in debugging.

Comments are text that is ignored by the compiler during compilation and execution in C++ or any other programming language. The two types of comments that can be used in a C++ program are as follows:

  1. Single-line comments
  2. Multi-line comments

Single-line comments in C++

Comments that span only one line are known as "single-line comments." Anything written after "//" is referred to as the content of the single-line comment. For example:

// C++ program to print "codescracker" on output console.
using namespace std;
int main()
   // cout<<"codescracker";

   return 0;

The above C++ example programme will produce the following output:


In the above example, the second "cout" statement will not be executed because I used "//" to make it a comment.

Multi-line comments in C++

Comments that span multiple lines are known as "multi-line comments." Anything written between "/*" and "*/" is referred to as a multi-line comment. For example:

using namespace std;
int main()
   /* The following statement
    * will print the text
    * "codescracker"
    * on the output console 

   return 0;

You will get the same output as in the previous example. You can also use "/* comment_content */" to write a single-line comment.

Hot C++ programming language topics

The following is a list of hot C++ programming language topics that will be covered in separate posts.

Here is a simple C++ program.

using namespace std;

int main()
   cout<<"C++ Tutorial at codescracker.com";
   return 0;

When the above C++ program is compiled and executed, it will produce the following output:

c++ tutorial

The preceding program was written, compiled, and executed in one of the most well-known IDEs for C++ programming. Let's take a look at another C++ example program.

// C++ Programming Tutorial - C++ Tutorial with Examples

#include <iostream>
#include <string>
using namespace std;

int main()
   string name;

   cout << "Enter your name: ";
   getline(cin, name);

   cout << "\nHey,\n" << name;
   cout << "!\nAre you ready?";

   cout << endl;
   return 0;

The following snapshot shows the initial output produced by the above C++ program.

c++ programming tutorial

Now type your name, say "Julia Roberts," and hit the ENTER key to produce the following output:

c++ programming

You will learn all about C++ programming, one by one, in this tutorial series.


This tutorial is designed and developed to help all those C++ programmers, who are interested in practice a lot of programs in C++, along with its description and tutorial.

We have included as many posts as are required to learn C++, along with its tutorial and examples.

In this tutorial series, we have included as many programs as required in each and every posts.


Before you start learning the C++ programming given here, you must have some basic computer skills. If you have it, then you can understand how to setup your environment to start programming in C++.

And if you know how to program, then it becomes very easy to learn C++ here.

C++ Quiz

« CodesCracker Home Next Tutorial »

Liked this post? Share it!