Computers Education Technology

Difference between C and C++

Main Difference

The main difference between both programming language is that C is a simple procedural language and simply follows the procedural programming prototype while C++ is a multi-prototype language that means it is both procedural and object oriented.

Advertisements

Comparison Chart

Basis of Distinction C C++
Nature Of Language C is a structural or procedural type of programming language. C++ is an object-oriented programming language and supports Polymorphism, Abstract Data Types, Encapsulation, among others. Even though C++ derives basic syntax from C, it cannot be classified as a structural or a procedural language.
Point Of Emphasis C lays emphasis on the steps or procedures that are followed to solve a problem. C++ emphasizes the objects and not the steps or procedures. It has higher abstraction level.
Compatibility With Overloading C does not support function overloading. C++ supports function overloading, implying that one can have name of functions with varying parameters.
Data Types C does not provide String or Boolean data types. It supports primitive & built-in data types. C++ provides Boolean or String data types. It supports both user-defined and built-in data types.
Compatibility With Exception Handling C does not support Exception Handling directly. It can be donethrough some other functions. C++ supports Exception Exception:Handling can be donethrough try & catch block.
Compatibility With Functions C does not support functions with default arrangements C++ supports functions with default arrangements.
Compatibility With Generic Programming C is not compatible C++ is compatible with generic programming
Pointers And References C supports only Pointers C++ supports both pointers and references.
Inline Function C does not have inline function. C++ has inline function.
Data Security In C programming language, the data is unsecured. Data is hidden in C++ and is not accessible to external functions. Hence, is more secure
Approach C follows the top-down approach. C++ follows the bottom-up approach.
Functions For Standard Input And Output scanf and printf cin and cout
Time Of Defining Variables In C, variable has to be defined at the beginning, in the function. Variable can be defined anywhere in the function.
Namespace Absent  Present
Division Of Programs The programs in C language are divided into modules and functions. The programs are divided into classes and functions in the C++ programming language.
File Extension .C .CPP
 Function And Operator Overloading Absent Present
Mapping Mapping between function and data is complicated in C. Mapping between function and data can be done easily using ‘Objects’.
Calling Of Functions main() function can be called through other functions. main() function cannot be called through other functions.
Inheritance Possible Not possible
Functions Used For Memory Allocation And Deallocation malloc() and calloc for Memory Allocation and free() function for Deallocation. New and delete operators are used for Memory Allocation and Deallocation in C++.
Influences C++, C#, Objective-C, PHP, Perl, BitC, Concurrent C, Java, JavaScript, Perl, csh, awk, D, Limbo C#, PHP, Java, D, Aikido, Ada 95
Influenced By B (BCPL,CPL), Assembly, ALGOL 68, C, ALGOL 68, Simula, Ada 83, ML, CLU
Level of Language Mid-level High-level
Classes C uses structures thereby, giving freedom to use internal design elements class and structures
Advertisements

C

C is an old system programming language developed by Dennis Ritchie in 1969. C has been accepted as an easy, flexible and powerful language used for programming of many applications, either it is for engineering programs or business programs. It was the upgraded version of B language of that time. UNIX operating system was the first operating system written in C and latest operating system like Windows and Linux, are also written in C language. Many computer architectures and operating systems are using this language. The advantages of C language are that it is a most reliable, portable, flexible, efficient, effective and interactive programming language. It is widely used in developing database systems, word processors, spreadsheets and operating system developments. At present 19% of the programs are developed in C programming language.

Advertisements

C++

C++ (Cee Plus Plus) is a multi-prototype, procedural, object-oriented, generic, and functional programming language that also provides the facilities for low-level memory manipulation. It was designed by Bjarne Stroustrup and was initially released in 1983. Latest version of C++ was released on December 15, 2014. C++ is an accumulated language that is used in many platforms and many organizations like FSF, LLVM, Microsoft, and Intel are using this language. It is considered as the recommended programming language to strengthen the software infrastructures and resource-constrained application such as desktop applications, servers (includes e-commerce, web search and SQL servers), performance critical applications (includes telephone switches or space probes), and entertainment software.

Key Differences

  • C is a simple procedural language and simply follows the procedural programming prototype while C++ is a multi-prototype language that means it is both procedural and object oriented.
  • C is a case sensitive program language, care is needed in case of programming in C language. While C++ is not a case sensitive language.
  • C mainly focuses on formal procedures or steps to solve any issue while C++ mainly focuses on objects instead of procedures or steps.
  • Data security is compromised in C, that’s why not recommended for data security. In C++, data is hidden and can’t be accessed by external workings.
  • C uses the top down approach while C++ uses the bottom up approach.
  • scanf() and printf() function are use in C for standard input and output while cin>> and count<< are use for standard input and output function in case of C++.
  • C is considered as a middle language while C++ is regarded as a high level language.
  • Over loading and operator overloading supports function is available in C++ while all these are lacking in C.

Video Explanation