0% found this document useful (0 votes)
32 views7 pages

Lecture3 05august CAP202

Uploaded by

suriraghav2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views7 pages

Lecture3 05august CAP202

Uploaded by

suriraghav2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Difference between C and

C++
No. C C++

1) C follows the procedural style programming. C++ is multi-paradigm. It supports both procedural and object oriented.

2) Data is less secured in C. In C++, you can use modifiers for class members to make it inaccessible for outside users.

3) C follows the top-down approach. C++ follows the bottom-up approach.

4) C does not support function overloading. C++ supports function overloading.

5) In C, you can't use functions in structure. In C++, you can use functions in structure.

6) C does not support reference variables. C++ supports reference variables.

7) In C, scanf() and printf() are mainly used for C++ mainly uses stream cin and cout to perform input and output operations.
input/output.

8) Operator overloading is not possible in C. Operator overloading is possible in C++.

9) C programs are divided into procedures and modules C++ programs are divided into functions and classes.

10) C does not provide the feature of namespace. C++ supports the feature of namespace.

11) Exception handling is not easy in C. It has to perform C++ provides exception handling using Try and Catch block.
using other functions.

12) C does not support the inheritance. C++ supports inheritance.


Difference between C and C++
Parameter C C++
The C programming language is a C++ is an object-oriented programming
Programming Style procedural language type. The language language type. The language is object-
is function-driven. driven.

C programming follows a top to down C++ follows a bottom-to-top approach


Approach programming approach that focuses on that focuses on data rather than the
the steps rather than the data. overall procedure.

As C is a structured programming
language, the program is divided into As C++ is an object-oriented
Program Division blocks known as functions which can be programming language, the code
viewed as individual components of the consists of Objects and Classes.
program.

Besides built-in data types, C++ also


C supports built-in data types. C is a basic
supports user-defined data types. C++ is
Data Types version of a programming language and
an enhanced version of C and supports
supports only primitive, fixed data types.
generic data types.
Contd…
C does not support exception handling, C++ supports exception handling and
Exception Handling i.e., support in times of ‘hard’ errors provides efficient support during errors
causing code problems. and incorrect codes.

C++ programming language is suitable


This programming language is more
and extensible for high-end programming
suitable for assemblers, text editors,
Application Development including game development, embedded
network drivers, and low-level
systems like smartwatches, medical
implementations.
machines, etc.

C is the foundational language and, hence, C++ is the superset of the C language
Compatibility the code written with C can be run with including OOP concepts and hence,
the C++ compiler. cannot run the code in the C compiler.

.c is the file extension for the C


File Extension .cpp is the file extension for C++.
programming language.

Also known as Hands-on language which C++ is a more object-oriented high-level


means C allows the programmer to tell programming language which requires
Ease Of Coding
everything. Therefore, one can program it fixed construction and principles.
the way we want. It is easy. However, it is easier to code.
Contd…
C programming language does not
adhere to the encapsulation C++ is a more secure programming
Data Security
concept and allows easy data language.
manipulation from outside code.
Inline Function C does not support inline function. C++ supports inline functions.
A variable is like a storage location
Variables in C++ can be declared
Variable and in C it needs to be defined at
anytime.
the beginning itself.
To organize the code for efficiency
and prevent collisions, namespace C++ as a flexible programming
Namespace
is required. C does not support language supports namespace.
that.
Contd…

C was the base of many


foundational languages and is itself C++ was developed, and inspired
Source code
known for its free format source by the C programming language.
code.
Microsoft Windows Kernel, Google Chrome, Microsoft Office,
Used By Telegram Messenger, Oracle Torque 3-D game engine, and so
Database, MySQL, etc. many more.
The C language uses a <studio.h> The C++ language uses a
Header Files
header file. <iostream.h> header file.
No access modifiers are present in Access modifiers are used in C++
Access Modifiers
the C structure. structures.
Contd…

For dynamic memory allocation, C With C++, memory allocation can


provides the malloc() and calloc() be performed by a new operator,
Memory Allocation/De-allocation
functions, as well as free() function and memory de-allocation can be
for memory de-allocation. accomplished by a delete operator.
Inheritance Inheritance is not supported by C. Inheritance is supported in C++.
The C language focuses on
Rather than focusing on methods
Focus methods or processes instead of
or procedures, C++ focuses on data.
data.
The C language does not support
In C++, virtual functions and friend
Virtual and Friend functions virtual functions or friend
functions are supported.
functions.

You might also like