In this tutorial you will learn about difference between C and C++ language i.e. C vs. C++. It is one of the most commonly asked question in technical interviews.
C programming language was developed by Dennis Ritchie in the year 1972 while C++ programming language was developed by Bjarne Stroustrup in the year 1983. C++ is a superset of C and contains all the features of C language. Still there are some difference between C and C++. Below I have shared the main differences between these two programming language.
Also Read: Difference between C++ and Java
Difference between C and C++
S. No.
|
C
|
C++
|
1
|
C is a structural or procedural programming language.
|
C++ is an object oriented programming language.
|
2
|
Emphasis is on procedure or steps to solve any problem.
|
Emphasis is on objects rather than procedure.
|
3
|
Functions are the fundamental building blocks.
|
Objects are the fundamental building blocks.
|
4
|
In C, the data is not secured.
|
Data is hidden and can’t be accessed by external functions.
|
5
|
C follows top down approach.
|
C++ follows bottom up approach
|
6
|
C uses scanf() and printf() function for standard input and output.
|
C++ uses cin>> and cout<< for standard input and output.
|
7
|
Variables must be defined at the beginning in the function. Modern C compilers such as gcc support the C99 and C11 standards, which allow you to declare a variable anywhere.
|
Variables can be defined anywhere in the function.
|
8
|
In C, namespace feature is absent.
|
In C++, namespace feature is present.
|
9
|
C is a middle level language.
|
C++ is a high level language.
|
10
|
Programs are divided into modules and functions.
|
Programs are divided into classes and functions.
|
11
|
C doesn’t support exception handling directly. Can be done by using some other functions.
|
C++ supports exception handling. Done by using try and catch block.
|
12
|
Features like function overloading and operator overloading is not present.
|
C++ supports function overloading and operator overloading.
|
13
|
C program file is saved with .C extension.
|
C++ program file is saved with .CPP extension.
|
If you found any information incorrect or know about some other difference between C and C++ then please mention it by commenting below.
Thanks for sharing 🙂
Verrrrrrrrrrrrrrry goooooooddd answerrrr4
Great work 🙂
Thanks for the info bro.
Very Nice
thanks for sharing
how pointers are used in c++?
Thanks a lot
You really should mention templates. And references.
Also, maybe a thing or two about the fact that “C++ is not a superset of C”. Most notably type casting, enums, const-correctness and linking.
https://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
what an idea sir g
Good list here, some interesting ideas That is a very useful list, Mike.
C can also be a bottom up approach.is’nt it….?
Nice information about c and c++
GOOD
in c program is divided into class and object not function because we can already implement it in class
thanks for sharing
Thank you…..
It does a great help to me.
In 7th difference you said that in C we can’t define variables anywhere except starting, but after latest ANSI C rules now we can define variables anywhere.
Thanks for sharing ,its helpfull
thank u so much i clearly understood the diffrencess,,
Gud explain
This is vry easy n good lang.
Easy to understand
Thnx u so much
This is very good ? ? ? ? ? ? ?
1. In C++, during memory allocation/reallocation, one function will be invoked [constructor/destructor]. but not in C.
2.In C++, Re-usability and maintainability is easy. But not in C.
3. In C++, Variable and functions are accessed thro’ object. In C, directly accessed with name of the variable / functions .
c is good for small code and c++ is god for large code.compiler gcc and g++
Its average
Thanks a lot bro
They are useful to them
thank you
thanks brother ..
thankyou verymuch
thank u so much
Nice, does anyone know what language virus protection is written in?
gud information about c and c++
Good explanation
It clarifies our problem in systematic way
Good info
Java is a combination of C and C++. But most of C++ features are added in the Java. The main advantage of java is it supports Web Application. It is robust,distributing and secured language in which C & C++ does not support.
These differences between C and C++ are very informative. I’ve getting much new things after reading your post. Thanks for sharing this useful knowledge.
Thanks