Difference Between C and C++

A programming language is a formal language that specifies a set of instructions that can be used to produce various kinds of output. Programming languages generally consist of instructions for a computer. A programming language is a formal computer language or constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs to control the behavior of a machine or to express algorithms. There are various programming languages in existence as of today, but we’ll see today that what is the difference between C and C++? Come let’s check it out below :

Basic Introduction :

  • C programming language was developed by Dennis Ritchie[1972] while C++programming language was developed by Bjarne Stroustrup[1983].
  • C++ is the derived form of C programming language. C is the subset of C++.
  • The major difference between C & C++ is that C does not support classes and objects as C is a procedural programming language, while on the other side C++ is a combination of both procedural and object oriented programming language.
  • The following table contains some of the major differences between C and C++.

Difference between C and C++

C

C++

1. C is a procedural (structural) programming language.

1. C++ is a procedural also an object oriented programming language.

2. C supports only built-in data types.

2. C++ supports both built-in and user defined data types.

3. Multiple declaration of global variables are allowed but variables must have to be defined at the beginning in the function.

3. Multiple declaration of global variables are not allowed but variables can be defined anywhere in the function.

4. No virtual functions are present in C.

4. The concept of virtual functions are used in C++.

5. C follows top-down approach.

5. C++ follows bottom-up approach.

6. Operator over-loading isn’t possible in C.

6. C++ allows operator over-loading.

7. Name space feature isn’t there in C programming language.

7. Name space feature is used in C++ to avoid name collision.

8. Here scanf() function is used for input.

printf() function is used for output.

8. Here cin>> function is used for input.

cout<< function is used for output.

9. malloc() and calloc() function is used for memory allocation.

free() function is used for memory de-allocation.

9. new operator is used for memory allocation.

free operator is used for memory de-allocation.

10. In C, polymorphism is not possible.

10. In C++, polymorphism is used, as polymorphism is the important feature of OOPS.

11. In C, inheritance is not possible.

11. In C++, inheritance is possible.

12. Exception handling is not present.

12. Try and catch block is used for exception handling.

13. Mapping between data and functions is difficult in C.

13. Data and functions are easily mapped through Objects.

14. C is a mid-level programming language.

14. C++ is a high-level programming language.

Hope now you would know really well the difference between C and C++. Thank you.

Leave a comment