Difference between C and C++

spot_img

In this Post you know the Difference Between C and C++ and also know about the Introduction of C and C++.

What is C Introduction

C Introduction:- C is a middle-level language. It was developed by Dennis Ritchie. It has the simplicity of a high-level language as well as the power of a low-level language. This aspect of C makes it suitable for writing both application programs and system software. Thus it is an excellent, efficient, and general-purpose language for most the applications such as mathematical, scientific, business and system software applications.

What is C++ Introduction

C++ Introduction:- C++ is an object-oriented programming language and it is also known as the structural programming language. C++ was developed by Bjarne Stroustrup at AT & T’s Bell Laboratory(USA) in 1979. C++ provides so many features such as Array, Structure, class, and object, constructor and destructure, inheritance, polymorphism, containership, encapsulation, sorting, queue, and linked list.

C and C++

Difference between C and C++

C

  1. C Language was developed by Dennis Ritchie in 1972 at AT & T’s Bell Labs.
  2. C is a subset of C++.
  3. C supports the procedural programming paradigm for code development.
  4. C does not support object-oriented programming; therefore it has no support for polymorphism, encapsulation, and inheritance.
  5. In C (because it is a procedural programming language), data and functions and separate and free entities.
  6. C being procedural programming, it is a function-driven language.
  7. C does not support function and operator overloading.
  8. C does not allow functions to be defined inside structures.
  9. C does not have a namespace feature.
  10. C uses functions for Input/Output for example scanf and printf.
  11. C does not support reference variables.
  12. C does not provide direct support for error handling(also called exception handling).
  13. C is a middle-level language.
  14. File extension in C is. C
  15. When a function takes no parameter, its prototype has the word void inside parenthesis.
    int fun(void);
  16. In C, prototypes are recommended but technically optional.
  17. In C, a nonvoid function is not required to actually a value. If it doesn’t, a garbage value is returned.
  18. In C, comments in the program can be specified by /…./
  19. In C local variables can be declared only at the start of a block prior to any action statements.
  20. In C, variables are of two types
  • Ordinary
  • Pointer
  1. C programmer follows a top-down approach for programming. It is a program design technique that starts with the highest level of an idea and works its way down to the lowest level of detail.

Example-

/* Write a program of a sum of two nums.

#include<stdio.h>

#include<cono.h>

void main()
{
int a=10, b=20, c;
crlscr();
sum=a+b;
printf(“sum=%d”, c);
getch();

}

C++

  1. C++ was developed by Bjarne Stroustrup in 1979 with C++’s predecessor “C with classes”.
  2. C++ is a superset of C. C++ can run most of C code while C cannot run C++ code.
  3. C++ supports both procedural and object-oriented programming paradigms; therefore C++ is also called hybrid language.
  4. C++ supports Object-Oriented Programming therefore C++ supports polymorphism, encapsulation, and inheritance.
  5. In C++ (as an object-oriented programming language), data and functions are encapsulated together in form of an object.
  6. While C++ is object-oriented programming, it is an object-driven language.
  7. C++ supports both function and operator overloading.
  8. In C++, functions can be used inside a structure.
  9. C++ uses a namespace that avoids name collisions.
  10. C++ uses functions for Input/Output for example Cin and Cout.
  11. C++ supports reference variables.
  12. C++ provides support for exception handling. exceptions are used for “hard” errors that make the code incorrect.
  13. C++ is a high-level language.
  14. File extention in C++ is .CPP
  15. However, in C++ the void is optional .
    int fun();
  16. In a C++ program, all functions must be prototyped.
  17. In C++, if a function is declared as returning a value, that is return type other than void, any return statement within that function must contain a value.
  18. In C++, due to backward compatibility, // is still used for multiple line comments. We can also make a single line as a comment by prefixing that line by //
  19. In C++ local variables can be declared anywhere in the block.
  20. In C++, variables are of three types
  • Ordinary
  • Pointer
  • Reference
  1. C++ programmer adopts bottom up approach for programming.

Example-

/* Write a program of sum of two number.

#include<stdio.h>

#include<conio.h>

void main()
{
int a=10, b=20, c;
clrscr();
c=a+b;
Cout<<“sum”<<c;
getch()
}

Final word

I hope you like today’s article, Difference between C and C++. If you have any queries or suggestions ask us in the comment below.

You can also join us on social media, share this article with your friends or families, and don’t forget to subscribe to it.

STAY HAPPY STAY HEALTHY

Thank You!

Author's Choice

Precisely what is the Best Antivirus Software?

It is hard to determine which is the best malware software, but if it's a Windows user...

Greatest Antiviruses Just for PC Gamers

One of the most critical factors for choosing the very best antivirus https://tech2gether.org/activating-avast-with-license-key for PERSONAL COMPUTER gamers certainly is the level...

Greatest Free VPN For Firestick

If you are looking for that free VPN for your Firestick, you can find some terrific options with regards to streaming. You may...

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here