C Vs C++

C and C++ are powerful computer programming languages used to develop programs that interact with computers. The distinction between C and C++ is a frequently encountered question in technical interviews. Dennis Ritchie originally crafted the C language at AT&T Bell Labs from 1969 to 1973, while Bjarne Stroustrup developed C++ at Bell Labs, commencing in 1979.

C Vs C++

Regarding their fundamental orientation, the C language primarily supports structured procedural programming. In contrast, C++ extends its capabilities to encompass object-oriented programming, generic programming, and metaprogramming, enabling the execution of arbitrary computations during compile time. The inception of C++ was motivated by the need to manage complexity that C alone could not effectively handle. Originally named "C with Classes" due to its basis in C, it was rechristened as C++ in 1983.

In essence, everything present in C is fully supported in C++. As a result, developers can leverage not only the new features introduced with C++ but also harness the power and efficiency of the C language. Conversely, the reverse is not true, and some C++ features cannot be utilized in C. Consequently, C++ can be described as a superset of C, incorporating all the features of the C language.

Here is a list of differences between c and c++:

C C++
File extension .c File extension .cpp
Default header file is stdio.h Default header file is iosteam.h
Structural or Procedural programming language. Object Oriented programming language.
Functions are the fundamental building blocks. Objects are the fundamental building blocks.
Top down approach is used in Program Design. Bottom up approach adopted in Program Design.
Call main() Function through other Functions Cannot call main() Function through other functions.
Supports only Pointers. Supports both pointers and references.
Focuses on method or process rather than data. Focuses on data rather than method or procedure.
Data and functions are separate and free entities. Data and functions are encapsulated together in form of an object.
Declare all the variables at the top of the program. Declared anywhere in the program before use.
Multiple Declaration of global variables are allowed. Multiple Declaration of global variables are not allowed.
Does not provide String or Boolean data types. It supports primitive & built-in data types. Provides Boolean or String data types. It supports both user-defined and built-in data types.
Does not have inline function. Has inline function.
Does not support reference variables. Supports reference variables.
Data is not secured. Data is hidden and can't be accessed by external functions.
No namespace features present Namespace feature present for avoiding collision
Does not support for virtual and friend functions. Supports virtual and friend functions.
Does not support function overloading. Supports function overloading.
Does not provide direct support for error handling . Can be done by using some other functions. C++ supports exception handling. Done by using try and catch block.
Does not support Encapsulation. Data and functions are separate and free entities. Supports encapsulation. Data and functions are encapsulated together in form of an object.
Concept of virtual functions is not present. Offers the facility of using virtual functions.


Although C and C++ share a substantial common foundation, there are notable differences between the two languages, making it essential for developers to understand the nuances and strengths of each language when choosing the appropriate one for a given project.