Difference Between C and C++

By: Rejin Paul
Jun 15,2018
0
{{ postlikes }}
{{ratedCustomerCount}} Post Rating

C vs C++

The beauty of computer science is anybody can program their own software of their wish . The only thing needed to develop a software is Programming Language.The first programming language was “FORTAN” and it was invented by IBM in the year 1954 . After analyzing the demand of software market the programming language also expanded to meet the requirements . There rises the two great programming language C and C++ . In this blog we are going to know “ WHY and WHY NOT C & C++ “.

BIRTH OF C :

The origin of C is closely related with the development of Unix Operating System , the difficulty developer faced was the language they used to code is a Low Level Language like Assembly languages so there is a need of some High level languages.By  understanding the demand Dennis Ritchie and  Ken Thompson , incorporated several ideas with their colleagues and they created a new high level programming language called C in the year 1972 . Thats how first full structured high level language stepped into the world of computer science.

BIRTH OF C++ :

As day passes by the computer generation faced many breakthroughs and challenges . During 1979 Bjarne Stroustroup found difficulty in integrating classes with the C language . So he did some research as his Ph.d thesis about the working rate of C language . He observed that practically C language not able  to develop the actual software and suffered from major object oriented bug problems. So to rectify it he invented C++ with upgraded syntax and structure related to object oriented programming.

DIFFERENCE BETWEEN C & C++:

This main theme of this blog is to show the difference between C & C++.So we show some major differentiation between them .

PROGRAMMING PARADIGM  : 

C supports procedural programming paradigm .It means the structure of C is based on procedural call . C++ is also known as Hybrid language because it supports both procedural and object oriented programming structure.

COMPILER APPROACH : 

Compiler is the tool which convert the high level language to low level language which system can understand .To compile the compiler approach the program in two basic step .The C program are approached by the compiler from top to bottom on the other hand C++ program is approached from bottom to top .

GENERIC PROGRAMMING : 

Generic Programming is a programming paradigm for developing efficient, reusable software libraries.C is non compatible generic programming language where else C++ contains all the qualities to be generic.       

POINTERS & REFERENCE :

This means we can refer other variable to another using their value or by their address . C supports only pointers but C++ supports both pointers and reference .                     

NAMESPACE :

Namespace is a class of elements (e.g. addresses, file locations, etc.) in which each element has a name unique to that class, although it may be shared with elements in other classes.C++ have namespaces due to its object oriented structure obviously C don't use namespaces.

FUNCTION & OPERATOR OVERLOADING : 

This means using same function or operator with various parameters for repetitive  use . C++ supports this type of functionality by C is limited with this specialty .                     

INHERITANCE :

Using the same class and its function in another class without redundantly  defining it is called as inheritance . Most of the large scale of the C++ program use inheritance to avoid redundancy  but C don't have this feature.     

DATA TYPES :

C++  provide boolean and string data types . It also supports both user defined and built-in data types . But C supports only primitive like int,float,char etc and built-in data type.

EXCEPTION HANDLING : 

C does not have any bulit-in exception handling function we have to define it explicitly . But C++ has a exception handing system called try-catch block where user can define their exception .

SECURITY : 

Data is hidden in C++ so no external function cannot access the data . C does not have any high security feature so it remains unsecured.

DEFINING VARIABLES :

The variables should be defined at the beginning of the function in C but in C++ we can define it anywhere.                        

EXAMPLE OF C PROGRAM :   

#include studio

// An example function that takes two parameters 'x' and 'y'

// as input and returns max of two input numbers

int max(int x, int y)

{

        if (x > y)

        return x;

        else

        return y;

}

// main function that doesn't receive any parameter and

// returns integer.

int main(void)

{

        int a = 10, b = 20;

        // Calling above function to find max of 'a' and 'b'

        int m = max(a, b);

        printf("m is %d", m);

        return 0;

}              

EXAMPLE OF C++ PROGRAM : 

#include iostream

#include conio

using namespace std;

// Simple factorial Function

int factorial(int var) {

    int fact = 1;

    for (int i = 1; i <= var; i++)

        fact = fact * i;

    return fact;

}

int main() {

    cout << "5 Factorial Number :" << factorial(5);

    getch();

    return 0;

}                      

CONCLUSION :

All programming languages has its own syntax and format . But all of them used for an specific purpose there is no general language . All the language are good at some point . Coming to C and C++ there are widely reached programming language which adapt to many software requirements.C and C++ has equal importance and share the same usability. 


Rejin Paul

Hello, Welcome to our Rejinpaul Network. we are Committed to provide educational services for students through our Important Threads in this Website. N.R.Rejinpaul,Founder / Rejinpaul Network working for the welfare of the students since 2010

comments

There is no Comment yet.

comment.username

{{ comment.username }}

{{ comment.date }}
{{ comment.comment }}
leave a comment

{{ commentMsg }}

Please Login & post your comments...

Create Account


This is required.
This is required.
This is required.
This is required.
This is required.
This is required.
This is required.
Male Female
This is required.
School College
This is required.
This is required.
{{registerMsg}}

Log In Your Account


This is required.
This is required.
{{loginMsg}}

Forgot Your Password?

Post Your Rating


your rating : {{ ratings.rating }}

{{ratingMsg}}