Search for Hubs, Articles and Topics
Search for Hubs, Articles and Topics

Difference Between C and C++

Learn about Difference Between C and C++

25 Jul 2021-4 mins read

C and C++ are two of the oldest programming languages still in use. Though C++ is a direct descendant of the C programming language, it has a higher level of efficiency and performance. Of course, each programming language has its own set of benefits and disadvantages.

The overview of the discussion about C vs c++ is that the C++ programming language is an upgraded version of the C programming language with the inclusion of object-oriented functionality.

Difference Between C and C++

Before we go into the details of the differences between C and C++, let’s take a glance at both languages.

What is C Programming Language?

The C programming language was created by Dennis Ritchie at Bell Labs in 1972 to allow utilities to run on Unix systems. Unix is an operating system belonging to a family of multiuser and multitasking operating systems.

The C programming language is a general-purpose and high-level language that facilitates structured programming. C was later on chosen as a system development language because it generates code that executes almost as quickly as an assembly language code.

Because C programs are fast, they allow programmers to manually control computer hardware.

The performance of the C programming language is its strength, and it can be used to code for a wide range of platforms. Operating systems, interpreters, compilers, and microcontrollers are some of the systems that use C language for their internal programming.

What is C++ Programming Language?

C++ was created by Bjarne Stroustrup and was considered the finest version of C when it first appeared in 1985. In 1979, while working at Bell Labs, Bjarne started developing the C++ programming language. He aimed to build a C extension that was more efficient and versatile than the C programming language.

Object-oriented programming (OOPS) is made possible using C++. OOPS is a concept in programming in which we write programs based on the principle of real world objects, like every object in the world has its own set of characteristics and functions to perform, similarly, object-oriented programming helps us to implement this approach through programming. OOPS has four basic principles as given below:

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

C++ has a low abstraction level and relies on manual memory management. The language is lightweight as compared to C programming language. C++ can be used to create apps for a number of different platforms.

C vs C++

ParametersCC++
Programming ParadigmProcedural languageC++ is both a procedural and object-oriented programming language (OOPS)
DeveloperDennis RitchieBjarne Stroustrap
OriginIt is based on Assembly LanguageIt is based on C language
Abstraction, Encapsulation, Inheritance, PolymorphismC does not support the given OOPS principles.C++ supports all of the given principles.
Operator OverloadingNot supportedSupported
KeywordsC has 32 keywords.C++ has 63 keywords
Constructor/DestructorNo constructor or destructor is supported in CBoth constructors and destructors supported
Exception HandlingNot supportedSupported
ApproachC uses top-down approachC++ uses bottom-up approach
Storage and dynamic memory allocationC uses functions- malloc and calloc for storage and dynamic memory allocationIt uses operators- new and delete for performing storage and dynamic memory allocation
Header filesUses header file- stdio.hUses header file- iostream.h
Standard I/O operationsUses printf and scanf for input and output operationsC++ uses cin>> and cout<< and also printf and scanf
TemplatesC does not supports templatesSupports templates
File extensionFile extension for a C program is .cFile extension for C++ program is .cpp
Program divisionThe program is divided into small codes known as functionsA C++ program is divided into small pieces of code known as classes and objects.
Inline functionC does not supports inline functionsC++ supports inline functions

Conclusion

We’ve looked at the primary differences between C and C++ in terms of different parameters in this tutorial.

We’ve seen that C is a procedural language and C++ is an object-oriented programming language and many features are unique only to C++. Because C++ is developed from C, it provides many of the same features as C.

:::