Introduction to C++

What is C++?

C++ is a cross-platform language that can be used to create high-performance applications. It was developed by Bjarne Stroustrup in 1979 at Bell Labs, as an extension to the C language and gives programmers a high level of control over system resources and memory. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

Why to Learn C++

  • C++ is one of the world’s most popular programming languages.
  • It can be found in today’s operating systems, Graphical User Interfaces, and embedded systems.
  • The object-oriented programming language functionality gives a clear structure to programs and allows code to be reused, lowering development costs.
  • It is portable and can be used to develop applications that can be adapted to multiple platforms.
  • C++ is a MUST for students and working professionals to become a great Software Engineer. Here are some of the key advantages of learning C++:
  • C++ is very close to hardware, so you get a chance to work at a low level which gives you lot of control in terms of memory management.
  • C++ is one of every green programming languages and loved by millions of software developers. If you are a great C++ programmer then you will never sit without work and more importantly you will get highly paid for your work.
  • C++ is the most widely used programming languages in application and system programming. So you can choose your area of interest of software development.
  • C++ really teaches you the difference between compiler, linker and loader, different data types, storage classes, variable types their scopes etc.

C++ is a super set of C programming with additional implementation of object-oriented concepts.

Hello World using C++

Here is a simple program which prints Hello World as an output

#include <iostream>
using namespace std;
// main() is where program execution begins.
int main() 
   cout << "Hello World"; // prints Hello World
   return 0;

 #include <iostream> is a header file library that lets us work with input and output objects, such as cout and cin.

Using namespace std means that we can use names for objects and variables from the standard library.

Another thing that always appear in a C++ program, is int main(). This is called a function. Any code inside its curly brackets {} will be executed. The function int main() ends with return 0.

cout is an object used together with the insertion operator << to output text. In our example it will output “Hello World”.

It should be noted that every C++ statement ends with a semicolon;.

The body of int main() can also be written as:
int main () { cout << “Hello World! “; return 0; } which will work in the same way as above program works.

The compiler ignores white spaces. However, multiple lines makes the code more readable.

If the main function is declared as int main() then it must return 0 at last of the program.

Do not forget to add the closing curly bracket } to actually end the main function.

The cout object, together with the << operator, is used to output values/print text:

You can add as many cout objects as you want. However, note that it does not insert a new line at the end of the output: