Friday, 30 January 2015

DIFFERENCE BETWEEN C AND C++

Faizan Ali contact:- 03235356409 email:- ali.faizan0009@hotmail.com


C++, as the name suggests, is a super set of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ & C..
1.    C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented)

2. In case of C, the data is not secured while the data is secured(hidden) in C++
3. C is a low-level language while C++ is a middle-level language
4. C uses the top-down approach while C++ uses the bottom-up approach
5. C is function-driven while C++ is object-driven
“Functions are the building blocks of a C program while objects are building blocks of a C++ program.”
6. C++ supports function overloading while C does not
“Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism (an OOP feature)”
7. We can use functions inside structures in C++ but not in C.
“In case of C++, functions can be used inside a structure while structures cannot contain 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 enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)”
9. The standard input & output functions differ in the two languages
“C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions”
10. C++ allows the use of reference variables while C does not

“Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming”

0 comments:

Post a Comment