Difference between C and C++ Language..
- C is procedure oriented programming (POP).
- In C programs are divided into small parts known as functions.
- Encapsulation,abstraction,Inheritance and polymorphism are not supported in C.
- Inline functions and virtual functions are not available in C.
- Function overloading and operator overloading are not possible in C.
- C uses scanf() and printf() functions for input/output.
- C uses malloc() and free() functions for dynamic memory allocation and dealloaction.
- C does not support exception handling.
- Filename extension is .
- 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++ supports both procedure oriented programming (POP) and object oriented programming(OOP).
- In C++ large programs are divided into smnaller parts known as objects.
- All of them are supported by C++.
- All of them are available in C++.
- All of them are possible in C++.
- C++ uses cin and cout objects for input/output.
- C++ uses new and free operators for dynamic memory allocation and deallocation.
- C++ supports for exception handling using try and catch.
- File name extension is .CPP.
- 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
Post a Comment