C++,as the name suggests, is a superset of C. As a matter of fact, C++ can run mostof C code while C cannot run C++ code. Here are the 10 major differences betweenC++ & C…
1.C follows the procedural programming paradigm while C++ is a multi-paradigmlanguage(procedural as well as object oriented)
Incase of C, importance is given to the steps or procedure of the program whileC++ focuses on the data rather than the process. Also, it is easier toimplement/edit the code in case of C++ for the same reason.
2.In case of C, the data is not secured while the data is secured(hidden) in C++
Thisdifference is due to specific OOP featureslike Data Hiding which are not present in C.
3.C is a low-level language while C++ is a middle-level language (Relatively,Please see the discussion at the end of the post)
Cis regarded as a low-level language(difficult interpretation & less userfriendly) while C++ has features of both low-level(concentration on whats goingon in the machine hardware) & high-level languages(concentration on theprogram itself) & hence is regarded as a middle-level language.
4.C uses the top-down approach while C++ uses the bottom-up approach
Incase of C, the program is formulated step by step, each step is processed intodetail while in C++, the base elements are first formulated which then arelinked together to give rise to larger systems.
5.C is function-driven while C++ is object-driven
Functionsare the building blocks of a C program while objects are building blocks of aC++ program.
6.C++ supports function overloading while C does not
Overloadingmeans two functions having the same name in the same program. This can be doneonly in C++ with the help ofPolymorphism(anOOP feature).
7.We can use functions inside structures in C++ but not in C
Incase of C++, functions can be used inside a structure while structures cannotcontain functions in C.
8.The NAMESPACE feature in C++ is absent in case of C
C++uses NAMESPACE which avoid name collisions. For instance, two students enrolledin the same university cannot have the same roll number while two students indifferent universities might have the same roll number. The universities aretwo different namespace & hence contain the same roll number(identifier)but the same university(one namespace) cannot have two students with the sameroll number(identifier).
9.The standard input & output functions differ in the two languages
Cuses scanf & printf while C++ uses cin>> & cout<< as theirrespective input & output functions.
10.C++ allows the use of reference variables while C does not
Referencevariables allow two variable names to point to the same memory location. Wecannot use these variables in C programming.