Comparison Between C & C++

This post describes the comparison between C and C++. While doing the comparison between C and C++ we’ll see the differences between C and C++ syntax and similarities between the two languages. This post also describes the basic introduction of the two languages and their real-world applications.

Introduction

Dennis M Richie” developed a procedural language named C in 1969 in Bell’s Laboratory. This language doesn’t support classes and objects. This language was based on assembly language for its origin.

C++ stands for c with classes. It is a procedural and object-oriented language developed by “Bjarne Stroustrup” in 1979. This language was based on C for its origin i.e. it is an extension to C.

Differences Between C & C++ Syntax

C LanguageC++ language
“printf” function is used to print any statement in C++.
Example: printf(“hello world”);
“cout” function is used to print any statement in C++.
Example: cout<<” hello world”;
“scanf ” function is used to store input in the variables.
Example: scanf(“&d”, a);
a is a variable d is the integer type
“cin” function is used to store input in the variables.
Example: cin>>a;
a is a variable
In C headerfile-“stdio.h”
is used to execute
input function (printf) and
Output function (scanf).
In C++ headerfile-“iostream.h”
is used to execute
Input function (cout) and
Output function(cin).
Program to add two numbers in C
Language
Program to add two numbers in C++ Language 
#include<conio.h>
# include<stdio.h>
 Void main() {
int a,b,sum;
printf(“enter two numbers”); scanf(“%d%d”,&a,&b);
sum=a+b;
print (“%d”,sum);
getch();
}
#include<conio.h>
   #include<iostream.h>
Void main() {
Int a,b,sum;
cout<<”enter two numbers”;
cin>>a>>b;
Sum=a+b;
cout<<sum;
getch();
}
File extension in C language is “.c”File extension in C++ language is “.cpp”
 The top-down approach is used for program design.The bottom-up approach used for program design.

Similarities Between C & C++:

  1. At the end of every line in the program, we use a semicolon (;) to end the line.
  2. These languages are translated to machine language by the compiler.
  3. Both the languages support pointers.
  4. Both languages support Storage classes.
  5. C and C++ are platform dependent.
  6. Both languages are case sensitive.

Real World Applications:

C Language:

  1. UNIX operating system was designed in C.
  2. Embedded System also uses C for programming.
  3. The most familiar photo-editor Adobe Photoshop uses C in its software designing.
  4. Due to the simplicity of code C lang. is directly or indirectly influenced in the development of the other languages for example c++, java, c# etc.

C++ Language:

  1. Many graphical user interfaces usages C++ for scripting. For Ex: adobe premiere, image ready etc.
  2. C++ language is used in the medical and engineering field for scripting advance software like MRI machines & high-end CAD/CAM system.
  3. It overrides the complexities of 3D Games.

Discover more from easytechnotes

Subscribe to get the latest posts sent to your email.

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top