C is a system programming language, developed in 1972 by Dennis Ritchie.
C++ is a general-purpose programming language, developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph).
Here’s a brief summary of how core functionality differs between these two:
Feature | C | C++ |
---|---|---|
Programming Paradigms | Procedural | Procedural and Object Oriented |
Level of Abstraction | Lowest | Low |
Execution flow | Top to bottom | Top to bottom |
Form of compiled source code | Executable code | Executable code |
Memory allocation | Uses malloc |
Uses new |
Memory deallocation | Uses free |
Uses delete |
Print statement | scanf() and printf() |
cin>> and cout<< |
String type | Character arrays | Character arrays and Objects |
Exception Handling | Use other functions | Use Try and Catch block. |
Here’s how data types compare:
Data types | C | C++ |
---|---|---|
Strings | No | Yes |
Boolean | Yes | Yes |
Structs | Yes | Yes |
Classes | No | Yes |
Lastly, C++ also supports some other useful things: Functions in Structures, Function Overloading, Operator Overloading, Inheritance, and Namespace. These don’t exist in C.
The following program prints Hello World in both C and C++ :
#include<stdio.h>int main() {printf("Hello World\n");return 0;}
Free Resources