C and C++ are popular programming languages used for system programming, application development, game development, and embedded systems. C is a procedural programming language, while C++ is an extension of C that supports both procedural and object-oriented programming concepts.
- C focuses mainly on functions and procedures.
- C++ supports classes, objects, inheritance, and polymorphism.
- Both languages are fast, efficient, and widely used in software development.
C language
C is a procedural programming language developed by Dennis Ritchie at Bell Labs in 1972. It is widely used for system programming, operating systems, and embedded systems.
- Follows a top-down programming approach.
- Mainly focuses on functions and procedures.
- Provides low-level memory access using pointers.
Example: Hello World Program
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
Output
Hello World
Explanation: Above program prints "Hello World" on the screen using the printf() function.
C++ language
C++ is an extension of the C programming language developed by Bjarne Stroustrup in 1979. It supports both procedural and object-oriented programming features.
- Follows both procedural and object-oriented programming paradigms.
- Supports classes, objects, inheritance, and polymorphism.
- Provides advanced features like function overloading and exception handling.
Example: Hello World Program
#include <iostream>
using namespace std;
int main() {
cout << "Hello World";
return 0;
}
Output
Hello World
Explanation: Above program prints "Hello World" on the screen using the cout object.
C Vs C++
| Feature | C | C++ |
|---|---|---|
| Programming Type | Procedural Programming Language | Multi-paradigm Language (Procedural + OOP) |
| Development Year | Developed in 1972 | Developed in 1979 |
| Developer | Dennis Ritchie | Bjarne Stroustrup |
| Programming Approach | Top-down approach | Bottom-up approach |
| Main Focus | Functions and procedures | Objects and classes |
| Object-Oriented Support | Not supported | Fully supported |
| Classes and Objects | Not available | Available |
| Inheritance | Not supported | Supported |
| Polymorphism | Not supported | Supported |
| Function Overloading | Not supported | Supported |
| Operator Overloading | Not supported | Supported |
| Exception Handling | Not available | Available |
| Namespace Support | Not available | Available |
| Data Security | Less secure | More secure due to encapsulation |
| Input/Output Functions | printf() and scanf() | cout and cin |
| Memory Management | Uses malloc() and free() | Uses new and delete |
| Standard Library | C Standard Library | Standard Template Library (STL) |
| File Extension | .c | .cpp |
| Use Cases | Operating systems, embedded systems | Applications, games, GUI software |