Difference Between C programming language and C++ programming language

The following are the differences between C and C++: C++ is an object oriented programming language. C is a structural programming language. C is a subset of C++.

Difference Between C programming language and C++ programming language
https://www.robotshapers.com/Difference-Between-C-programming-language-and-C-programming-language

C

C is a general-purpose, procedural computer programming language supporting .

A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix. It was applied to re-implementing the kernel of the Unix operating system. It has become one of the most widely used programming languages, with C compilers from various vendors available for the majority of existing computer architectures and operating systems. C has been standardized by the ANSI since 1989 (ANSI C) and by the International Organization for Standardization (ISO).

C is an imperative procedural language. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.

C++

Where as C++ is a general-purpose programming language invented by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language.

C++ was designed with a bias toward system programming and embedded, resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its design highlights.

C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2017 as (informally known as C++17). The C++ programming language was initially standardized in 1998. The current C++17 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Danish computer scientist Bjarne Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization.

Here’s the basic difference between the C and C++ Language:-                    

Basis of

distinction

C

C++

Designed by

Dennis Ritchie

Bjarne Stroustrup

First appeared

1972-1973

1985

Programming type

It is a Procedural language.

It is an Object-Oriented Programming language.

Approach

 

 

C language follows Top Down programming

Approach.

C++ follow bottom-up programming approach.

File extension

 

The file extension of a C program is .c / .h

The file extension of a C++ program is .cpp/.C/.cc/.cxx/.c++/.h

/.hh/.hpp/.hxx/.h++

Program division

 

 

In C programming language, a big program code is

divided into small pieces which are called functions.

In C++ programming language, a big program code is divided into Objects and Classes.

Structure

 

 

Structure in C does not provide the feature of

function declaration.

Structure in C++ provides the feature of declaring

a function as a member function of the structure.

Inline function

 

It does not allow inline function.

It supports inline function.

 

Standard I/O operations

 

 

In C, scanf and printf are used for the standard

input and output.

In C++, cin» and cout« are used for standard input

and output operations.

Data Security

 

 

In C language the data is not secured.

Data is secure, so it can't be accessed by external

functions. (Using Encapsulation concept of OOPs)

Ease of Coding

 

 

 

 

 

C is an older programming language that is

described as Hands-on. In this language, you must

tell the program to do everything.

C++ is an extension language of C. It allows for the

highly controlled object-oriented code.

Compatibility with other

languages

C is not compatible with another language.

 

C++ is compatible with the other generic

programming languages.

Pointer  

 

C supports only Pointers.

C++ supports both pointers and references.

Variable

In C, the variable should be defined at the

beginning of the program.

C++ allows you to declare variables anywhere in

the function.

Point of Focus

C focuses on the steps or procedures that are

followed to solve a problem.

C++ emphasizes the objects and not the steps or

procedures. It has higher abstraction level.

Function Overloading

C does not allow you to use function overloading.

C++ allows you to use function overloading.

Data Types

C language does not allows you to declare String

or Boolean data types. It supports built-in and

primitive data types.

C++ supports String and Boolean data types

Exception Handling

 

C does not support Exception Handling. However,

it can be performed using some workarounds.

 

C++ supports Exception handling. Moreover, this

operation can be performed using try and catch

block.

Functions

 

Does not allows functions with default

Arrangements.

Allow functions with default arrangements.

Namespace

 

It is absent in C language.

It is present in the C++ language.

Source Code

Free-format program source code.

 

Originally developed from the C programming

language

Relationship

 

C is a subset of C++. It cannot run C++ code.

 

C++ is a superset of C. C++ can run most of C code

while C cannot run C++ code

Driven by

Function-driven language

Object-driven language

Focus

 

 

Focuses on method or process instead of

data.

Focuses on data instead of method or

procedure.

Encapsulation

Does not support encapsulation. As Data

and functions are separate and free entities.

Supports encapsulation. Data and functions are

encapsulated together as an object.

Information hiding

C does not support information hiding. In

this language, data are free entities and can be changed outside code.

Encapsulation hides the data. So that data

structures and operators are used as per intention.

Memory management

C provide malloc() and calloc() functions

for dynamic memory allocation.

C++ provides a new operator for this purpose.

 

Data Types

Supports built-in data types.

Supports built-in & user-defined data types.

Global Variables

Allows Multiple Declaration of global Variables.

Multiple Declaration of global variables are not allowed.

Concept of Mapping

 

 

The mapping between Data and Function is very complicated.

The mapping between Data and Function can be easily established using "Classes and Objects."

Inheritance

Inheritance is not supported in C.

Inheritance is possible in C++ language.

Default header file

C used stdio.h header file.

C++ uses iostream.h as default header file.

Virtual function

The concept of virtual Functions is present

in C.

The concept of virtual Function is not used in

C++

Keywords

Contain 32 keywords.

Contains 52 keywords.

Polymorphism

In C Polymorphism is not possible.

The concept of polymorphism is used in C++.

Polymorphism is one of the most Important

Features of OOPS.