Search

C vs C++

Updated: Dec 12, 2020

What is C ?

C is the oldest language but it is still the part of our syllabus in colleges/universities

C is a structural or procedural oriented programming language which is machine-independent and extensively used in various applications.

C is the basic programming language that can be used to develop complex programs like Oracle database - MySQL, Git, Python interpreter, and many more. C can be used from the various operating systems (like Windows XP, 7, 8, 8.1, 10). C language was developed by one of the computer scientist Dennis Ritchie at the Bell Laboratories. C can be programmed in various compiling software including Turbo C++, Dev C++, Code Blocks, VS Code. C also have graphics which we will study in detail in C tutorial.


What is C++ ?

C++ also known as Cpp is the advanced version of C. It contains all the features of C but something is extra here & That is OOPS. Oops is object oriented programming which is sued to solve real world problems. Also, Oops have various features including Data Hiding, Code reusability which is not present in C.

In simple words we can say that

C++ = C + Oops



There are lot of other difference between C & C++. Let’s see them in the below table.


S No.

C Language

C++ Language

0.

Only supports procedural style programming

Supports Both Procedural & Object Oriented Programming

1.

Very Less Security of Data in C

Data is more secured in C++

2.

Top Down Approach

Bottom Up Approach

3.

Function Overloading – Not Supported

Function Overloading is supported in C++

4.

You can’t use functions/procedures in structures

You can use functions/procedures in structures

5.

Reference Variables – Not Supported

Reference Variables - Supported

6.

Input function – scanf, Output Function – printf

Input function – cin, Output Function – cout

7.

Operator Overloading – Not Possible

Operator Overloading – Possible

8.

Programs are divided into procedures & modules

Programs are divided into function & classes

9.

Namespace, Inheritance – Not Supported

Namespace, Inheritance – Supported


Some Other Differences (if you want to cover 20 marks question)

  • Let’s See Definition First ! C is a structural programming language, and not supports any classes and objects, But C++ is an object-oriented programming language that supports the concept of classes and objects, polymorphism & lot more.



  • Programming Language Types ? C supports the structural programming language where the code is checked line by line, while C++ is an object-oriented programming language that supports the concept of classes and objects. Both works on Compiler.

  • Who Developed these Languages ? Dennis Ritchie developed C language at Bell Laboratories while C++ Language is developed by Bjarne Stroustrup at Bell Labs circa 1980.

  • C++ > C C++ is a superset of C programming language. C++ can run 99% of C code but C language cannot run C++ code.

  • Type of approach C follows the top-down approach, while C++ follows the bottom-up approach. The top-down approach breaks the main modules into tasks; these tasks are broken into sub-tasks, and so on. The bottom-down approach develops the lower level modules first and then the next level modules.

  • Function Overloading Function overloading is a feature that allows you to have more than one function with the same name but varies in the parameters. C does not support the function overloading, while C++ supports the function overloading.

  • Function Overriding Function overriding is a feature that provides the specific implementation to the function, which is already defined in the base class. C does not support the function overriding, while C++ supports the function overriding.

  • Security Level In C, the data can be easily manipulated by the outsiders as it does not support the encapsulation and information hiding while C++ is a very secure language, i.e., no outsiders can manipulate its data as it supports both encapsulation and data hiding. In C language, functions and data are the free entities, and in C++ language, all the functions and data are encapsulated in the form of objects.

  • Reference variables C does not support the reference variables, while C++ supports the reference variables.

  • Keywords in C & C++ C contains 32 keywords, and C++ contains 52 keywords.

  • Namespace feature (using namespace std) A namespace is a feature that groups the entities like classes, objects, and functions under some specific name. C does not contain the namespace feature, while C++ supports the namespace feature that avoids the name collisions.

  • Exception handling C does not provide direct support to the exception handling; it needs to use functions that support exception handling. C++ provides direct support to exception handling by using a try-catch block.

  • Input/Output functions of header file In C, scanf and printf functions are used for input and output operations, respectively, while in C++, cin and cout are used for input and output operations, respectively. Syntax is very easy In C++ as compared to C.

  • Memory allocation and de-allocation C supports calloc() and malloc() functions for the memory allocation, and free() function for the memory de-allocation. C++ supports a new operator for the memory allocation and delete operator for the memory de-allocation.

  • Inheritance Inheritance is a feature that allows the child class to reuse the properties of the parent class. C language does not support the inheritance while C++ supports the inheritance. Inheritance is used for code reusability, which is a very good feature given in C++ as it saves a lot of space & time.

  • Header file Header file in C is #include<stdio.h> but in C++ header file is #include<iostream.h>. Additional header file used for C is #include<conio.h> But in C++, no additional header file is required to implement basic operations.

---------------------------------------------------------------------------------------------------------------------

Previous Page Next Page

Any Doubt ? Feel free to write a comment

Download C++ Projects

Join us on LinkedIn – Great Place of Networking

Follow us on More Together – Facebook for regular updates

Mandatory to join Telegram group for regular job updates

Mandatory to join whatsapp group for regular job updates



Other C++ Topics




For Other Tutorials – Click Here




5 views0 comments

Related Posts

See All

Number to Character Conversion in C++

Program to implement Number to Character Conversion in C++ Firstly see what we are going to do ? Like this 0 - zero 1 – one 2 – two 3 – three 4 – four 5 – five 6 – six 7 – seven 8 – eight 9 – nine How

Factorial of a number in C++

In this tutorial we are going to see how to find a factorial of number using C++ program Firstly let’s see a example to understand it better n! = n + (n-1) + (n-2) ! n>=1 3! = 3 *2*1 = 6 Program to fi

Fibonacci Triangle in C++

Program to implement Fibonacci Triangle in C++ #include <iostream> using namespace std; int main() { int a=0,b=1,i,c,n,j; cout<<"Enter the limit: "; cin>>n; for(i=1; i<=n; i++) { a=0; b=1; cout<<b<<"\

Info © Copyright 2020-21 Fresher Side. All rights reserved. Contact us