Escolar Documentos
Profissional Documentos
Cultura Documentos
Prepared by : M.D.Vishwakarma
Rohini Chouhan
Designation: Assistant Professor
HARDWARE REQUIREMENT
• PENTIUM I (200 GHZ)
• 128 MB RAM
• 20 GB HDD
SOFTWARE REQUIREMENT
• WINDOWS 9x or above
• Language C ++
LIST OF EXPERIMENTS
1. WAP to add, subtract, multiply and divide two numbers using concepts of C++.
3. WAP to calculate volume of cube, cylinder, rectangular box using three times function overloading
in C++.
9. WAP to demonstrate the use of Local Object, Static Object & Global Object using C ++.
10. WAP in C++ to demonstrate the creation and the use of dynamic object.
11. Create two classes DM and DB which store the value of distances.
12. Derive the two classes son and daughter and, demonstrate polymorphism in action.
13. Create a base class called shape. Use this class to store two double type values that could be used to
compute the area of figures.
PROGRAM 1: WAP to add, subtract, multiply and divide two numbers using
concepts of C++.
#include<iostream.h>
#include<conio.h>
class math
{
float a,b;
public:
void getval()
{
cout<<"\n\nEnter two values ";
cin>>a>>b;
cout<<"\nyou enter a="<<a;
cout<<"\nyou enter b="<<b;
}
void add()
{
cout<<"\n\nADDITION is "<<a+b;
}
void sub()
{
cout<<"\n\n SUBSTRACTION is "<<a-b;
}
void mult()
{
cout<<"\n\n MULTIPLICATION is "<<a*b;
}
void div()
{
cout<<"\n\n DIVISION is "<<a/b;
}
};
void main()
{
int i,t;
clrscr();
class math obj;
obj.getval();
cout<<"\n\n************************************************";
cout<<"\n\nFor Addition press --> 1";
cout<<"\n\nFor Subtraction press --> 2";
cout<<"\n\nFor Multiplication press --> 3";
cout<<"\n\nFor Division press --> 4";
cout<<"\n\n************************************************";
cout<<"\n\n\nplesae enter value ";
while(t==0){
cin>>i;
cout<<"\n\n-----------------------------------------------";
switch(i)
{
case 1:
obj.add();
break;
case 2:
obj.sub();
break;
case 3:
obj.mult();
break;
case 4:
obj.div();
break;
default:
cout<<"\n\nWrong choise";
}
cout<<"\n\nfor Exit press any key or want more operation press 0 --> ";
cin >>t;
if(t==0)
cout<<"\nSelect new operarion ";
}
getch();
}
PROGRAM 2: WAP to show swapping of two numbers using C++.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter a: ";
cin>>a;
cout<<"Enter b: ";
cin>>b;
cout<<"Before swapping:"<<endl;
cout<<"a: "<<a<<" b: "<<b<<endl;
c=a;
a=b;
b=c;
cout<<"After swapping:"<<endl;
cout<<"a: "<<a<<" b: "<<b;
getch();
}
PROGRAM3: WAP to calculate volume of cube, cylinder, rectangular box
using three times function overloading in C++.
#include<iostream.h>
#include<conio.h>
void main()
{
int volume(int);
long volume(double,int);
long volume(long,int,int);
int main()
{
cout<<volume(10)<<"\n";
cout<<volume(2.5,8)<<'\n";
cout<<volume(100l,75,15)<<"\n";
return 0;
}
int volume(int s)
{
return(s*s*s);
}
double volume(double r,int h)
{
return(3.14519*r*r*h);
}
long volume(long l, int b, int h)
{
return(i*b*h);
}