Skip to main content

Difference in C and C++ language

  Difference between C and C++ Language..

  • C                        

  1. C is procedure oriented programming (POP).
  2. In C programs are divided into small parts known as functions.
  3. Encapsulation,abstraction,Inheritance and polymorphism are not supported in C.
  4. Inline functions and virtual functions are not available in C.
  5. Function overloading and operator overloading are not possible in C.
  6. C uses scanf() and printf() functions for input/output.
  7. C uses malloc() and free() functions for dynamic memory allocation and dealloaction.
  8. C does not support exception handling.
  9. Filename extension is .
  10. Follows top down approach in program design.
Example...1.Program to add two numbers.
#include <stdio.h>
#include<conio.h>
void main()
  int a,b,c;
  printf("Enter two numbers :");
  scanf("%d,%d",&a,&b);
  c=a+b;
  printf("Addition is : %d",c);
  getch();
}


  •    C++


  1. C++ supports both procedure oriented programming (POP) and object oriented programming(OOP).
  2. In C++ large programs are divided into smnaller parts known as objects.
  3. All of them are supported by C++.
  4. All of them are available in C++.
  5. All of them are possible in C++.
  6. C++ uses cin and cout objects for input/output.
  7. C++ uses new and free operators for dynamic memory allocation and deallocation.
  8. C++ supports for exception handling using try and catch.
  9. File name extension is .CPP.
  10. Follows bottom up approach in program design.
Example....1.Program to add two numbers.
#include<iostream.h>
#include<conio.h>
class add
{
  int a,b;
  public:
  void getNumbers()
   {
     cout<<"Enter two numbers : ";
     cin>>a>>b;
  }   
  void addNumbers()
{
  cout<<"Addition of numbers is : "<<a+b;
}
};
void main()
{
  add a1;
  clrscr();
  a1.getNumbers();
  a2.addNumbers();
  getch();   
}

REFERENCES :
https://www.programmingsimplified.com/cpp/source-code/add-numbers

Comments