what is the main difference between c and c++?
Answer Posted / anirudh sony
1. C follows the procedural programming paradigm while C++
is a multi-paradigm language(procedural as well as object
oriented)
In case of C, importance is given to the steps or
procedure of the program while C++ focuses on the data
rather than the process.
Also, it is easier to implement/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++
This difference is due to specific OOP features like
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)
C is regarded as a low-level language(difficult
interpretation & less user friendly) while C++ has features
of both low-level(concentration on whats going on in the
machine hardware) & high-level languages(concentration on
the program itself) & hence is regarded as a middle-level
language.
4. C uses the top-down approach while C++ uses the bottom-up
approach
In case of C, the program is formulated step by step,
each step is processed into detail while in C++, the base
elements are first formulated which then are linked together
to give rise to larger systems.
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
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is an advantage of polymorphism?
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
Is oop better than procedural?
What is new keyword in oops?
What is destructor in oop?
What is oops in simple words?
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.
What is inheritance in simple words?
How Do you Code Composition and Aggregation in C++ ?
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
What does and I oop and sksksk mean?
What is oops with example?
What polymorphism means?
I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...