What is C and C++

This is one of the most asked question in the Computer Science courses. If you have done a computer science, information technology or related courses, chances are that you’ve faced this question asking you to explain “major differences between C and C++ programming languages”. And of course, most of you would have listed several such differences. Let’s explore this important question and make a comprehensive list of differences between C and C++

Before, we get into a bit technical stuff let’s recap what are C and C++. Well, C is probably the most widely used computer programming language. C was originally developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. The reason why C has been so popular lies in the efficiency with which C converts into machine instructions. This efficiency has made the applications written in C super-fast.

A list of differences between C and C++ programming languages.

Major differences between C and C++

Following table contains various points where C and C++ programming languages differ from each other.

1C is a procedural (aka structural) programming language.In addition to begin procedural, C++ is also an object oriented programming language.
2In C language, the solution is achieved through a sequence of procedures or steps. Therefore, C is a function driven language.C++ can model the whole solution in terms of objects and that makes the solution better organized. C++ is an object driven language.
3Concept of virtual functions is not present in C.C++ offers the facility of using virtual functions.
 4Operator overloading is not possible in C.C++ allows operator overloading.
 5Data in C functions is not secured. Data can be easily accessed by other external functions.All the data in C++ can be put inside objects. This provides better data security.
6C is a middle level language.C++ is a high level language.
SEE ALSO:Difference between C++ and Java
 7C programs are divided into modules and procedures.C++ programs are divided into classes and functions.
 8C programs use top-down approach.C++ programs use bottom-up approach.
9In C, the main() function can be called from other functions.In C++, the main() function can not be called from other functions. The program execution begins from main() function.
10C language does not provide the feature of namespace.Namespaces are available in C++.
 11Exception handling is not easy in C. It has to be done by using other functions.C++ provides exception handling through Try and Catch block.
12Inheritance is not possible in C.Because C++ is an object oriented language, inheritance is possible.
13In C, all the variables must be declared at the beginning of a scope.C++ allows declaring variables anywhere within the scope. This allows us to declare a variable when we use it for the first time.
14In C, function overloading is not possible. Function overloading is to use two functions with the same name within a scope.Function overloading is possible in C++
15Standard Input in C is received through scanf() function whereas standard output is given through printf() function.C++ uses cin>> and cout>> as standard input and output functions respectively.
16C programs are saved in files with extension .cC++ programs are saved in files with extension .cpp
17Mapping between data and functions is difficult in C.In C++ data and functions are easily mapped through objects.
 18In C, polymorphism is not possible.Being a fully object oriented language, C++ offers polymorphism.
19C supports only built-in data types.C++ supports both built-in and user-defined data types.

C++ is the object oriented and updated version of C language.Therefore, C++ not only shares a lot of C features but also provides new features, such as object-orientation. As a result, most of the C++ compilers can also compile C programs. Following Vann diagram shows how C and C++ share features and how different they are:

C++ contains almost all of C.

The following graph shows the usage of various programming languages between 2002 and 2015.

Comparison of usage of various programming languages during 2002 and 2015. Source: TIOBE index.

As you can see, the use C language has been more or less steady during last 14 years. In comparison, Java and C++ have been going out of favor.

In the end, there is a video by Satish B in which he explains how to switch from C to C++.

So, these are the major differences between C and C++ programming languages. Of course, there are lots of other differences as well, do let me know if you want me to include anything in the list. Thank you for using TechWelkin.

Last updated: | Published on: | Authored and Edited by:Lalit Kumar and Team | Filed as: Home » Programming » Difference Between C and C++ Programming Languages

Filed Under: Programming