Introduction to C++ Programming

Introduction to C++ programming language. What is the C++ language? Who developed the C++ programming language? In this tutorial Introduction to C++ language, you will learn Different versions of C++ programming language, C++ applications, how to compile and run C++ programs, and how to write hello world program in C++ programming language.

C++ is a general-purpose, High level, Compiled based and object-oriented programming(OOP) language, developed by Bjarne Stroustrup in AT&T Bell Labs. The C++ language is an extended version of C Programming Language, and it is pronounced as “C-plus-plus”. C and C++ are often denoted together as C/C++.

The C++ programming language is considered to be an intermediate-level language, as it encapsulates both high- and low-level language features. Initially, the language was called “C with classes” as it had all the properties of the C language with an additional concept of “classes.” However, it was renamed C++.

Different versions of C++

C++ versionYear
C++981985
C++032003
C++11 (C++0x)2011
C++14 (C++0y)2014
C++17 (C++0z)2017
C++202020

C++ Applications

There are a lot of things that can be designed using the C++ programming language.

  • Operating System:- Linux , Windows, Apple(OS X) e.t.c
  • Text Editor:- Notepad, Wordpad, Editplus e.tc
  • Database:- Oracle, SQL Server, MySQL e.t.c
  • Translator:- Compiler, Interpreter, Assemble e.t.c
  • Protocols:- HTTP, FTTP, e.t.c
  • Commercial Application:- Bank, Super Market, Hotel Management program e.t.c
  • Device Drivers:- Drivers of Mouse, Printer, Keyboard e.tc
  • PC and Mobile games

Many Other systems, applications, and, libraries are completely or mostly written in C++. Facebook, Adobe Systems, Amazon, Google, Chromium Browser, Google File system, Mozilla (Firefox browser and Thunderbird mail client) are a famous example of the applications of C++. For more applications visit this.

The translator converts source code to object code. Compiler, Interpreter and, Assemble are an example of a Translator. Compiler & Interpreter converts the high-level language to machine code, Assemble converts the low-level language to machine code.

We use Compiler as a Translator for C++. Therefore, C++ is also called as a compiler-based programming language.

For Protocols, C++ used Especially. Whenever we open a website, automatically it starts with HTTP (HyperText Transfer Protocol), HTTP designed with C++. Similarly, C++ is also used to design FTP (File transfer protocol) and Bluetooth transfer protocols. In short, 90% of telecom protocols are designed using C++ Programming Language.

Compile and Run C++ Programming

C++ Programming language can be run online. There are various Websites that allow running C++ online. Some websites are ideone.com, C++ Shell. But, there are some limitations to online compilers like we can’t work with files.

Its recommended to install a compiler and run C programs from the system to unlock the full potential of C++.

To run C++ Programming in Windows you can use Code: Blocks IDE. For this, go to the official website of Code: Blocks, and download it.

Developing C++ Program in Linux OS

Code: Blocks IDE is also available for Linux. The best approach for Linux is to compile and run using the terminal. For this purpose, we need a compiler, development tools & libraries, and a text editor.

$ sudo apt-get update
$ sudo apt-get install gcc

This installs GNU GCC compiler and related tools on your system.
We may also run the below command,

$ sudo apt-get install build-essential

This command will install all the libraries which are required to compile and run a C++ program.

Issue the below command to verify GCC compiler is installed properly or not,

$ gcc --version

Write any C++ Program using any text editor and save it as .cpp extension. Don’t Forget to use .cpp extension. Now open the terminal, switch to the directory where the file is located. Let we wrote a C++ program and save it as program.cpp

These command compile program.cpp and create an executable file named program.

$ g++ program.cpp -o program

To see the output use the following command,

$ ./program

Note:- Shortcut to compile C++ program in terminal (Linux)

For compilation, This command creates an executable file named a.out
$ g++ program.cpp

Execute it,
$ ./a.out

Introduction to Hello World! Program in C++

In every programming language, we start our journey by writing the hello world program. In this tutorial Introduction to C++ programming language, you will learn how to write a program to display “Hello World” to the screen. The below program displays “Hello World” to the screen.

#include <iostream>
using namespace std;
int main()
{
  cout << "Hello World!";
  return 0;
}

Output:-

Hello World!

How this program works,

#include <iostream>

This line includes the iostream header file. The #include directive tells the compiler to include a file. iostream is a standard C++ input/output library file.

using namespace std;

This line tells the compiler that we are "using" the "namespace" "std" in our file. We use the namespace std to make it easier to reference operations included in that namespace.

If we hadn’t used the namespace, we had written std::cout instead of cout. This tells the compiler that every cout is actually std::cout.

A semi-colon ; is used to end a statement. Semi-colon character at the end of the statement is used to indicate that the statement is ending there.

int main() {}

This line declares a function main which returns integer data. Every C++ program must have a main function. Execution of every C++ program starts from the main function. The code inside {} is called the body of the main function, the opening braces ‘{‘ indicates the opening of the main function and the closing braces ‘}’ indicates the end of the main function.

cout << "Hello World!";

This line tells the compiler to display the message Hello World!

return 0;

This is the return statement used to return a value from a function and indicates the finishing of a function.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!

Leave a Comment

Your email address will not be published. Required fields are marked *