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 Language | C++ 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++:
- At the end of every line in the program, we use a semicolon (;) to end the line.
- These languages are translated to machine language by the compiler.
- Both the languages support pointers.
- Both languages support Storage classes.
- C and C++ are platform dependent.
- Both languages are case sensitive.
Real World Applications:
C Language:
- UNIX operating system was designed in C.
- Embedded System also uses C for programming.
- The most familiar photo-editor Adobe Photoshop uses C in its software designing.
- 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:
- Many graphical user interfaces usages C++ for scripting. For Ex: adobe premiere, image ready etc.
- C++ language is used in the medical and engineering field for scripting advance software like MRI machines & high-end CAD/CAM system.
- It overrides the complexities of 3D Games.
Discover more from easytechnotes
Subscribe to get the latest posts sent to your email.