Why to use languages like C++?

7 min 20 sec read Basic

At its core, the computer is just a processor which is capable of running the instructions like "Store 10 in memory location 2020". Why would we express a program as a text file in a programming language, instead of writing processor instructions?

Advantages of C++

  1. Portability
  2. Mid-level programming language
  3. Object-Oriented
  4. Multi-paradigm programming language
  5. Memory Management
  6. Fast and Powerful
  7. Similar to other languages
  8. Standard Library
  9. Community
  10. Scalability

1) Portability

In simple words, Portability in C++ allows the developers to write the code without caring much about the hardware. For example, you are working on Windows OS and for some reason, you have to switch to LINUX, the codes from Windows OS will also run in the LINUX OS without any error.

2) Mid-level programming language

As C++ supports the high-level programming features like developing the games and software applications along with the low-level programming features like developing the kernel and drivers to interact with the machine.

3) Object-Oriented

Object oriented programming as the name suggests, it is referring to an object.It aims to implement real-world entities like inheritance, hiding, polymorphism etc. The main aim of OOP is to bind the data and functions together so that no other part can access this data except that function. We will explore this topic in depth in coming tutorials.

4) Multi-paradigm programming language

You can think of Programming paradigms as the way to write the code. Generally, it is a best practice to plan the logic, the style, and how to implement the specific program and get it into action. C++ basically supports three paradigms,

  1. Generic – Using a single idea that serves multiple purposes.
  2. Imperative – Using steps that change the state of the program.
  3. Object-Oriented – Using methods and classes for reusability and modularity.

5) Memory Management

C++ supports the memory allocation in runtime. The runtime memory allocation is also called the Dynamic Memory allocation. Using calloc(), malloc(), free(), realloc() functions, c++ reserves the space in the memory.

6) Similar to other languages

C++ syntax is almost similar to most of the programming languages like C, C#, Java. C++ is a superset of C. That means, we can run all the C programs in C++ with .cpp extension

7) Standard Library

With better library support, C++ allows the programmer to develop the software applications much faster and cleaner. There are many built-in libraries available in C++.

8) Community

Communities that support C++ are very large in numbers. This makes C++ even more powerful because there are a lot of people who can provide help and support in case if you get stuck somewhere during development.

9) Scalability

Being in the IT industry, scalability is very important. As the number of users who use the application grows, it is important that applications should scale in that case. C++ provides scalability.

Hello World C++

Lets begin with the basic C++ program. Open codzify online C++ compiler and write this basic C++ program to see it in action.

#include <iostream>
using namespace std;

int main() {
 // your code goes here
  cout<< "Welcome to C++";
  return 0;


Welcome to c++

To run the C++ program, there are many editors like Notepad++, Visual Studio Code where you can write your C++ program without any internet connection. After code completion, you have to save it with some filename and .cpp extension. For example, we have saved our c++ code as filename.cpp Filename can be any name which signifies the purpose of that file. 

How to run a C++ program?

Open terminal in Mac, Linux or Command Prompt in Windows. Access the directory where your C++ file is stored. In our case, it is saved as "abc.cpp" file on desktop. Last step you have to perform is run the following commands one by one in the terminal or command prompt

cd Desktop
g++ abc.cpp

Welcome to C++

Line-By-Line Explanation

1) #include tells the preprocessor to dump in the contents of another file, here the iostream file, which defines the procedures for input/output.

2) When we want to access an identifier defined in a namespace, we tell the compiler to look for it in that namespace using the scope resolution operator (::). Here, we’re telling the compiler to look for cout in the std namespace, in which many standard C++ identifiers are defined.

4) int main() {...} defines the code that should execute when the program starts up

5) cout  is used to print the statements . It is like scanf() and printf() in C.language

6) return 0;  is used to return an int value because specified returntype before main() function is int .

Comments in C++

C++ Comment is written as follows:

1) /* This is a multi-line 
        comment syntax */

2) // This is single line comment syntax


An Identifiers in C++ are simply the names used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9). C++ does not allow punctuation characters such as @, $, and % within identifiers. C++ is a case-sensitive programming language. Thus, Programming and programming are two different identifiers in C++.

Tokens in C++

Every C++ program consists of various tokens. Tokens in C++ can either be a keyword, an identifier, a constant, a string literal, or a symbol. There are 4 tokens in the given example below,

cout                    --> 1st token
<<                      --> 2nd token
"Welcome to C++"        --> 3rd token                               
;                       --> 4th token

So this was the basic introduction to C++ programming. We will learn more about Datatypes, Access Modifiers, Pointers, Functions in C++, etc in the upcoming articles. 

How was the tutorial? Nice. Right?

Deep Concept videos to crack the highly-piad interviews.

Chekout out our Youtube Channel to get detailed video content on important topics in interviews.

What is your Interview Score?

Test your skillset with the curated questions created by experts around the globe.

Book a free test slot. Now !.

It usually takes 30 mins for an online test and this test will be MCQ based. Get detailed analytics based on your test and recommedations with personalised roadmaps.

Book a test slot. Now!

Have questions about the trial coding class?

Chat with our experts to discuss

Connect on WhatsApp

Recommended tutorials

#online compiler for c     #python for programming    

#dfs and bfs algorithm     #programming with c language

#storageclass in C    #listcomprehension in python