SlideShare une entreprise Scribd logo
1  sur  47
INDEX
S.NO DATE TOPIC PAGE
NO
STAFF
SIGNATURE
1 DISTANCE CONVERSION
PROBLEM
1
2 OVERLOADING OBJECTS 10
3 OVERLOADING
CONVERSIONS
16
4 OVRELOADING MATRIX 22
5 AREA COMPUTATION
USING DERIVED CLASS
32
6 VECTOR PROBLEM 37
7 INHERITANCE 43
EX.NO:1
DATE:
DISTANCE CONVERSION PROBLEM
AIM:
Create two classes DM and DB which store the value of distances. DM
store the value ofdistances. DM stores distances in meters and centimeters in
DB in feet and inches. Write a Programthat can create the values of the class
objects and add one object DM with another object DB.
Use a friend function to carry out addition operation. The object that
stores the result may be DM object or DB objectdepending on the units in
which results are required.
The display should be in the order of meter and centimeter and feet or
inches depending on the order of display.
ALGORITHM:
STEP 1:
Start the program execution.
STEP 2:
To create a class metric and british.
STEP 3:
To create a function input() and display().
STEP 4:
Accept the feet,inches value of british.
STEP 5:
Accept the meter ,cm,value of metric.
STEP 6:
To convert metric value to british value.
STEP 7:
To convert british value to metric value.
STEP 8:
To display the metric values and british values.
STEP 9:
Stop the program execution.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
class metric;
class british
{
public:
int feet,inches;
void input();
friend british addbritish(british & b,metric & m);
void display();
};
class metric
{
public:
int meter,cm;
void input();
friend metric addmetric(metric & m,british & b);
void display();
};
void british::input()
{
cout<<"nt enter the value of feet:";
cin>>feet;
cout<<"nt enter the value of inches:";
cin>>inches;
}
british addbritish(british & b,metric & m)
{
british b1;
int ftin,tmcm,tin,mtcm,tm,cm,tmcmtin,tot;
ftin=(b.feet)*12;
tin=ftin+b.inches;
mtcm=(m.meter)*100;
tmcm=mtcm+m.cm;
tmcmtin=tmcm/2.5;
tot=tin+tmcmtin;
b1.feet=tot/12;
b1.inches=tot%12;
return(b1);
}
void british::display()
{
cout<<"nt the feet value is:t"<<feet;
cout<<"nt the inches value is:t"<<inches;
}
void metric::input()
{
cout<<"nt enter the value of meter:t";
cin>>meter;
cout<<"nt enter the value of cm:t";
cin>>cm;
}
metric addmetric(metric & m,british & b)
{
metric m1;
int tin,ftin,mtcm,tincmt,tot;
ftin=(b.feet)*12;
tincmt=(ftin+b.inches)*2.5;
mtcm=(m.meter)*100;
tot=tincmt+mtcm+m.cm;
m1.meter=tot/100;
m1.cm=tot%100;
return(m1);
}
void metric::display()
{
cout<<"nt the meter value is t"<<meter;
cout<<"nt the centimeter value is t"<<cm;
}
void main()
{
int op;
clrscr();
british b1,b2;
metric m1,m2;
cout<<"nDistance conversion";
b1.input();
m1.input();
do
{
clrscr();
cout<<"nMENU";
cout<<"n1.Metric to British";
cout<<"n2.British to Metric";
cout<<"n3.Exit";
cout<<"nEnter the choice:";
cin>>op;
switch(op)
{
case 1:
cout<<"nt metric to british";
cout<<"nt output";
b1.display();
m1.display();
b2=addbritish(b1,m1);
cout<<"nt output";
b2.display();
break;
case 2:
cout<<"nt british to metric";
cout<<"nt output";
b1.display();
m1.display();
m2=addmetric(m1,b1);
cout<<"noutput";
m2.display();
break;
case 3:
cout<<"nexit";
break;
}
getch();
}
while (op!=3);
}
OUTPUT
Distance conversion
enter the value of feet: 10
enter the value of inches: 6
enter the value of meter: 4
enter the value of cm: 2
MENU
1.Metric to British
2.Britishto Metric
3.Exit
Enter the choice:1
metric to british
output
the feetvalue is: 10
the inches value is: 6
the meter value is 4
the centimetervalue is 2
output
the feetvalue is: 23
the inches value is: 10
MENU
1.Metric to British
2.Britishto Metric
3.Exit
Enter the choice:2
british to metric
output
the feetvalue is: 10
the inches value is: 6
the meter value is 4
the centimetervalue is 2
output
the meter value is 7
the centimetervalue is 17
MENU
1.Metric to British
2.Britishto Metric
3.Exit
Enter the choice:3
Exit
RESULT
EX.NO:2
DATE:
OVERLOADING OBJECTS
AIM:
Create a class FLOAT that contains one float data member overload all
the four arithmetic operators so that operate on the objects of FLOAT.
ALGORITHM :
STEP 1:
Start the program execution
STEP 2:
To create a class FLOAT
STEP 3:
Accept the input values
STEP 4:
Overloadthe arithmetic operator+
STEP 5:
Overloadthe arithmetic operetor–
STEP 6:
Overloadthe arithmetic operator*
STEP 7:
Overloadthe arithmetic operator/
STEP 8:
To display the output values.
STEP 9:
Stop the program execution.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
class FLOAT
{
float x,D;
public:
FLOAT()
{
}
FLOAT(float a)
{
x=a;
}
FLOAT operator+(FLOAT);
FLOAT operator-(FLOAT);
FLOAT operator*(FLOAT);
FLOAT operator/(FLOAT);
void outdata();
void indata()
{
cout<<"nnt enter the value:";
cin>>x;
}
};
FLOAT FLOAT::operator+(FLOAT D)
{
FLOAT temp;
temp.x=x+D.x;
return(temp);
}
FLOAT FLOAT::operator-(FLOAT D)
{
FLOAT temp;
temp.x=x-D.x;
return(temp);
}
FLOAT FLOAT::operator*(FLOAT D)
{
FLOAT temp;
temp.x=x*D.x;
return(temp);
}
FLOAT FLOAT::operator/(FLOAT D)
{
FLOAT temp;
temp.x=x/D.x;
return(temp);
}
void FLOAT::outdata(void)
{
cout<<x<<endl;
}
int main()
{
FLOAT o1,o2,ADD,SUB,MUL,DIV;
clrscr();
o1.indata();
o2.indata();
ADD=o1+o2;
SUB=o1-o2;
MUL=o1*o2;
DIV=o1/o2;
cout<<"nnt o1:";
o1.outdata();
cout<<"nnt o2:";
o2.outdata();
cout<<"nnt ADDITION VALUE IS (o1+o2)=";
ADD.outdata();
cout<<"nnt SUBTRACTION VALUE IS (o1-o2)=";
SUB.outdata();
cout<<"nnt MULTIPLICATION VALUE IS (o1*o2)=";
MUL.outdata();
cout<<"nnt DIVISION VALUE IS (o1/o2)=";
DIV.outdata();
getch();
return(0);
}
2.OUTPUT:
enter the value:4
enter the value:4
o1:4
o2:4
ADDITION VALUE IS (o1+o2)=8
SUBTRACTION VALUE IS (o1-o2)=0
MULTIPLICATION VALUE IS (o1*o2)=16
DIVISION VALUE IS (o1/o2)=1
RESULT:
EX.NO:3
DATE:
OVERLOADING CONVERSIONS:
AIM:
Designa class polarwhich describes a point in a plane using polar
Co-ordinates radius and angle. A point in polar Co-ordinates is as shown
below.
Use the overloader+ operatorto add two objects of polar. Note that we
cannot add polar values of two points directly. This requires first the
conversion.
Points into rectangular Co-ordinates and finally converting the result
into polar Co-ordinates.
You need to use following trigonometric formulas.
X= r * cos (a); Y= r * sin (a);
a= sqrt (X * X +Y * Y);
ALGORITHM :
STEP 1:
Start the program execution.
STEP 2:
To create class polar.
STEP 3:
Accept the radius and angle values.
STEP 4:
First we acceptthe radius and angle value is 0.
STEP 5:
To create arguments in polar.
STEP 6:
To overload the + operatorto add two object of polar.
STEP 7:
To display the output values.
STEP 8:
Stop the program execution.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
class polar
{
double radius,angle;
public:
polar()
{
radius=0;
angle=0;
}
polar(double r,double a)
{
radius=r;
angle=a;
}
void disp();
polar operator+(polar);
};
void polar::disp()
{
cout<<"nnt radius value is:";
cout<<radius;
cout<<"nnt angle value is:";
cout<<angle;
}
polar polar::operator+(polar p1)
{
polar p2;
double x1,x2,y1,y2,x,y;
x1=radius*cos(angle*3.14/180);
x2=p1.radius*cos(p1.angle*3.14/180);
y1=radius*sin(angle*3.14/180);
y2=p1.radius*sin(p1.angle*3.14/180);
cout<<"noutputn";
cout<<"*****n";
cout<<"nn radius 1="<<x1<<"tangle 1="<<y1;
cout<<"nn radius 2="<<x2<<"tangle 2="<<y2;
x=x1+x2;
y=y1=y2;
cout<<"nn sum of the radius in rectangularcoordinates is:";
cout<<x;
cout<<"nn sum of the angle in rectangularcoordinates is:";
cout<<y;
p2.radius=sqrt(x*x+y*y);
p2.angle=atan(y/x)*(180/3.14);
return(p2);
}
void main()
{
clrscr();
cout.precision(2);
polar o1,o2,o3;
double r1,r2,a1,a2;
char c;
do
{
cout<<"nenter the radius 1 and angle 1:";
cin>>r1>>a1;
cout<<"nenter the radius 2 and angle 2:";
cin>>r2>>a2;
o1=polar(r1,a1);
o2=polar(r2,a2);
o3=o1+o2;
o3.disp();
cout<<"nn Do you want to continue(y/n):";
cin>>c;
}
while(c=='y'||c!='n');
getch();
}
3.OUTPUT
enter the radius 1 and angle 1:
11
13
enter the radius 2 and angle 2:
13
15
output
*****
radius 1=10.72 angle 1=2.47
radius 2=12.56 angle 2=3.36
sum of the radius in rectangularcoordinates is:23.28
sum of the angle in rectangularcoordinates is:3.36
radius value is:23.52
angle value is:8.23
Do you want to continue(y/n):n
RESULT:
EX.NO:4
DATE:
OVRELOADING MATRIX:
AIM:
Create a class MAT of size M*N. Define all possible matrix operations
for MAT type objects. Verify the identity.
(A-B)^2 = A^2+B^2 –2*A*B
ALGORITHM :
STEP 1:
Start the program execution.
STEP 2:
To create a class MAT.
STEP 3:
To acceptthe elementof matrices.
STEP 4:
To create a function inp(int) and disp().
STEP 5:
To overload the operatorthe operators +,-,*,/,^.
STEP 6:
To using for condition.
STEP 7:
To acceptthe elementof first and secondmatrix.
STEP 8:
To calculate (A-B)^2.
STEP 9:
To calculate A^2+B^2-2*A*B.
STEP 10:
To verify (A-B)^2=A^2+B^2-2AB the identity is true using it condition.
STEP 11:
To verify (A-B)^2!=A^2+B^2-2AB the given identity is false.
STEP 12:
To create a output values.
STEP 13:
Stop the program execution.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
constsize=3;
class mat
{
int nrc;
int a[size][size];
public:
void inp(int);
void disp();
mat operator+(mat);
mat operator-(mat);
mat operator*(mat);
mat operator*(int);
mat operator^(int);
int operator==(mat);
};
void mat::inp(int n)
{
nrc=n;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
cin>>a[i][j];
}
void mat::disp()
{
for(int i=0;i<nrc;i++)
{
for(int j=0;j<nrc;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
}
mat mat::operator+(mat m)
{
mat temp;
temp.nrc=nrc;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
temp.a[i][j]=a[i][j]+m.a[i][j];
return temp;
}
mat mat::operator-(mat m)
{
mat temp;
temp.nrc=nrc;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
temp.a[i][j]=a[i][j]-m.a[i][j];
return temp;
}
mat mat::operator*(mat m)
{
mat temp;
temp.nrc=nrc;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
{
temp.a[i][j]=0;
for(int k=0;k<nrc;k++)
temp.a[i][j]+=a[i][j]*m.a[i][j];
}
return temp;
}
mat mat::operator*(int x)
{
mat temp;
temp.nrc=nrc;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
temp.a[i][j]=x*a[i][j];
return temp;
}
mat mat::operator^(int)
{
mat temp;
temp.nrc=nrc;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
{
temp.a[i][j]=0;
for(int k=0;k<nrc;k++)
temp.a[i][j]+=a[i][j]*a[i][j];
}
return temp;
}
int mat::operator==(mat m)
{
int t=1;
int f=0;
for(int i=0;i<nrc;i++)
for(int j=0;j<nrc;j++)
if(a[i][j]!=m.a[i][j])
return f;
else
return t;
return 0;
}
void main()
{
clrscr();
mat m1,m2,mat1,mat2;
int n;
cout<<"nenter the order of matrices:";
cin>>n;
cout<<"nenter the element of first matrix:";
m1.inp(n);
cout<<"nenter the element of secondmatrix:";
m2.inp(n);
cout<<"nfirst matrix is:";
m1.disp();
cout<<"nsecondmatrix is:";
m2.disp();
mat1=(m1-m2)^2;
cout<<"nresult of (A-B)^2 is:n";
mat1.disp();
mat2=(m1^2)+(m2^2)-((m1*m2)*2);
cout<<"nresult of (A^2+B^2-2AB)is:n";
mat2.disp();
if(mat1==mat2)
cout<<"nthe given identity is true:n";
else
cout<<"nthe given identity is false:n";
getch();
}
4.OUTPUT:
enter the order of matrices:2
enter the element of first matrix:
1
1
1
1
enter the element of secondmatrix:
1
1
1
1
first matrix is:
1 1
1 1
secondmatrix is:
1 1
1 1
result of (A-B)^2 is:
0 0
0 0
result of (A^2+B^2-2AB)is:
0 0
0 0
the given identity is true:
RESULT:
EX.NO:5
DATE:
AREA COMPUTATION USING DERIVED CLASS
AIM:
Area of rectangle = X*Y
Area of triangle = ½ * X * Y
ALGORITHM :
STEP 1:
Start the program execution.
STEP 2:
To create a class rectangle andtriangle.
STEP 3:
Create a function get(),cal()and disp().
STEP 4:
Accept the two sides of rectangles and triangle.
STEP 5:
Calculate the area of rectangle are=X*Y.
STEP 5:
Calculate the area of triangle are =1/2*X*Y.
STEP 6:
Display the outputs.
STEP 7:
Stop the program execution.
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
class rectangle
{
float area;
protected:
float x,y;
public:
void get();
void calc()
{
area=x*y;
}
void disp();
};
void rectangle::get()
{
cout<<"nenter the sides of rectangle and triangle:";
cin>>x>>y;
}
void rectangle::disp()
{
cout<<"narea of the rectangle is:"<<area<<endl;
}
class triangle:public rectangle
{
float area;
public:
void calc()
{
area=(x*y)/2;
}
void disp()
{
cout<<"narea of the triangle is:"<<area;
}
};
void main()
{
clrscr();
triangle tr;
tr.get();
tr.rectangle::calc();
tr.rectangle::disp();
tr.calc();
tr.disp();
getch();
}
5.OUTPUT:
enter the sides of rectangle and triangle:
4
5
area of the rectangle is:20
area of the triangle is:10
RESULT:
EX.NO:6
DATE:
VECTOR PROBLEM:
AIM:
Define a class forvector containing scalarvalues. Apply overloading
concepts for vectoraddition, Multiplication of a vectorby a scalarquantity,
replace the values in a position vector.
ALGORITHM
STEP 1:
Start the program execution.
STEP 2:
To create a class vector.
STEP 3:
To acceptthe input values.
STEP 4:
Overloading the *,+,<<,>>operators.
STEP 5:
To multiply the vector values.
STEP 6:
To calculate the sum of two vectors.
STEP 7:
To change the position of elements to be modified vector.
STEP 8:
To acceptthe input values.
STEP 9:
To display the output values.
STEP 10:
Stop the program execution.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
constsize=3;
class vector
{
public:
int *v;
vector()
{
v=new int[size];
}
int & operator[](int);
friend vector operator*(int,vector);
friend vector operator+(vector,vector);
friend istream & operator>>(istream&,vector&);
friend ostream& operator>>(ostream&,vector&);
};
int &vector::operator[](int pos)
{
return v[pos];
}
vectoroperator * (int a,vectorb)
{
vectorc;
for(int i=0;i<size;i++)
c.v[i]=a*b.v[i];
return c;
}
vectoroperator+(vectora,vectorb)
{
vectorc;
for(int i=0;i<size;i++)
c.v[i]=a.v[i]+b.v[i];
return c;
}
istream & operator>>(istream&cin,vector&b)
{
for(int i=0;i<size;i++)
cin>>b.v[i];
return cin;
}
ostream&operator<<(ostream&cout,vector&b)
{
cout<<","<<b.v[0];
for(int i=1;i<size;i++)
{
cout<<","<<b.v[i];
}
return cout;
}
void main()
{
clrscr();
vectorm,n;
int sc;
cout<<"nenter the elementof vector1:";
cin>>m;
cout<<"nenter the elementof vector2:";
cin>>n;
cout<<"noutput";
cout<<"n****************";
cout<<"nvector1_"<<m;
cout<<"nvector2_"<<n;
vectorsum,mul;
cout<<"nscalarmultiplication value:";
cin>>sc;
mul=sc * m;
sum=m+n;
cout<<"nscalarmultiplication of vector 1 is:"<<mul;
cout<<"nsum of the two vector is :"<<sum;
int pos,nval;
cout<<"nenter the positionof the element to be modified (vector):";
cin>>pos;
cout<<"nnenter the value:";
cin>>nval;
m[pos-1]=nval;
cout<<"nnmodified value is:"<<m;
getch();
}
6.OUTPUT
enter the element of vector 1:
5
6
4
enter the element of vector 2:
4
8
6
output
****************
vector1:5,6,4
vector2:4,8,6
scalarmultiplication value:3
scalarmultiplication of vector1 is: 15,18,12
sum of the two vectoris : 9,14,10
enter the position of the element to be modified (vector):2
enter the value:5
modified value is:5,5,4
RESULT:
EX.NO:7
DATE:
INHERITANCE
AIM:
Create three classes alpha, beta and gamma, eachcontaining one data
member. The class gamma should be inherited from both alpha and beta. Use
a constructorfunction in the class gamma to assignvalues to the data
members of all the classes.
ALGORITHM:
STEP 1:
Start the program execution.
STEP 2:
To create a three classes alpha, beta and gamma
STEP 3:
To acceptthe input values.
STEP 4:
TO use constructorfunction
STEP 5:
To acceptthe input values.
STEP 6:
To display the output values.
STEP 7:
Stop the program execution.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
class alpha
{
int x;
public:
alpha(int i)
{
x=i;
cout<<"alpha intialisedn";
}
void show_x(void)
{
cout<<"x="<<x<<"n";
}
};
class beta
{
float y;
public:
beta(floatj)
{
y=j;
cout<<"beta initializedn";
}
void show_y(void)
{
cout<<"y="<<y<<"n";
}
};
class gamma:public beta,public alpha
{
int m,n;
public:
gamma(int a,floatb,int c,int d):alpha(a),beta(b)
{
m=c;
n=d;
cout<<"gamma initializedn";
}
void show_mn(void)
{
cout<<"m="<<m<<"n";
cout<<"n="<<n<<"n";
}
};
void main()
{
clrscr();
gamma g(5,10.75,20,30);
g.show_x();
g.show_y();
g.show_mn();
getch();
}
7.OUTPUT
beta initialized
alpha intialised
gamma initialized
x=5
y=10.75
m=20
n=30
RESULT:

Contenu connexe

Tendances (20)

C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
New presentation oop
New presentation oopNew presentation oop
New presentation oop
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
week-3x
week-3xweek-3x
week-3x
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
C lab programs
C lab programsC lab programs
C lab programs
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
oop objects_classes
oop objects_classesoop objects_classes
oop objects_classes
 
Metnum
MetnumMetnum
Metnum
 
C programms
C programmsC programms
C programms
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
C++ file
C++ fileC++ file
C++ file
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 

En vedette

Basic resume for all jobs
Basic resume for all jobsBasic resume for all jobs
Basic resume for all jobsKarthik Awd
 
Anhoring Script For Annual Function
Anhoring Script For Annual FunctionAnhoring Script For Annual Function
Anhoring Script For Annual FunctionAnushkaSahu
 
Desenhos para pano de prato para imprimir
Desenhos para pano de prato para imprimirDesenhos para pano de prato para imprimir
Desenhos para pano de prato para imprimircamp desenhos
 
3Com 69-000205-06
3Com 69-000205-063Com 69-000205-06
3Com 69-000205-06savomir
 
Modello unità di apprendimento ub d fase 3
Modello unità di apprendimento ub d fase 3Modello unità di apprendimento ub d fase 3
Modello unità di apprendimento ub d fase 3limparando
 
Political alert house of representatives daily program, monday 20 march 2017
Political alert   house of representatives daily program, monday 20 march 2017Political alert   house of representatives daily program, monday 20 march 2017
Political alert house of representatives daily program, monday 20 march 2017Lisa Munoz
 
Political alert house of representatives daily program, tuesday 21 march 2017
Political alert   house of representatives daily program, tuesday 21 march 2017Political alert   house of representatives daily program, tuesday 21 march 2017
Political alert house of representatives daily program, tuesday 21 march 2017Lisa Munoz
 
Junta del 4 bimestre
Junta del 4 bimestreJunta del 4 bimestre
Junta del 4 bimestreJenny Angel
 
Jess presentation1
Jess presentation1Jess presentation1
Jess presentation1John Hall
 
anguilla catamaran charters /anguilla boat charters
anguilla catamaran charters /anguilla boat charters anguilla catamaran charters /anguilla boat charters
anguilla catamaran charters /anguilla boat charters sxmboatcharters
 
proyecto de pesquisa del cáncer de mama capítulos I, II y III
proyecto de pesquisa del cáncer de mama capítulos I, II y III proyecto de pesquisa del cáncer de mama capítulos I, II y III
proyecto de pesquisa del cáncer de mama capítulos I, II y III angelly servita
 
educational course/tutorialoutlet.com
educational course/tutorialoutlet.comeducational course/tutorialoutlet.com
educational course/tutorialoutlet.comjorge0043
 

En vedette (13)

Basic resume for all jobs
Basic resume for all jobsBasic resume for all jobs
Basic resume for all jobs
 
Prize Giving Speech
Prize Giving SpeechPrize Giving Speech
Prize Giving Speech
 
Anhoring Script For Annual Function
Anhoring Script For Annual FunctionAnhoring Script For Annual Function
Anhoring Script For Annual Function
 
Desenhos para pano de prato para imprimir
Desenhos para pano de prato para imprimirDesenhos para pano de prato para imprimir
Desenhos para pano de prato para imprimir
 
3Com 69-000205-06
3Com 69-000205-063Com 69-000205-06
3Com 69-000205-06
 
Modello unità di apprendimento ub d fase 3
Modello unità di apprendimento ub d fase 3Modello unità di apprendimento ub d fase 3
Modello unità di apprendimento ub d fase 3
 
Political alert house of representatives daily program, monday 20 march 2017
Political alert   house of representatives daily program, monday 20 march 2017Political alert   house of representatives daily program, monday 20 march 2017
Political alert house of representatives daily program, monday 20 march 2017
 
Political alert house of representatives daily program, tuesday 21 march 2017
Political alert   house of representatives daily program, tuesday 21 march 2017Political alert   house of representatives daily program, tuesday 21 march 2017
Political alert house of representatives daily program, tuesday 21 march 2017
 
Junta del 4 bimestre
Junta del 4 bimestreJunta del 4 bimestre
Junta del 4 bimestre
 
Jess presentation1
Jess presentation1Jess presentation1
Jess presentation1
 
anguilla catamaran charters /anguilla boat charters
anguilla catamaran charters /anguilla boat charters anguilla catamaran charters /anguilla boat charters
anguilla catamaran charters /anguilla boat charters
 
proyecto de pesquisa del cáncer de mama capítulos I, II y III
proyecto de pesquisa del cáncer de mama capítulos I, II y III proyecto de pesquisa del cáncer de mama capítulos I, II y III
proyecto de pesquisa del cáncer de mama capítulos I, II y III
 
educational course/tutorialoutlet.com
educational course/tutorialoutlet.comeducational course/tutorialoutlet.com
educational course/tutorialoutlet.com
 

Similaire à 12

Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxssuser3cbb4c
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Codemotion
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたAkira Maruoka
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Languagemadan reddy
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxhappycocoman
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdfannucommunication1
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 

Similaire à 12 (20)

Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
Pointers
PointersPointers
Pointers
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
Oop1
Oop1Oop1
Oop1
 
Opp compile
Opp compileOpp compile
Opp compile
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
Ch3
Ch3Ch3
Ch3
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
 
C lab programs
C lab programsC lab programs
C lab programs
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 

Plus de Pandiya Rajan

Plus de Pandiya Rajan (20)

CICD.pptx
CICD.pptxCICD.pptx
CICD.pptx
 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
 
css1.pptx
css1.pptxcss1.pptx
css1.pptx
 
HTML-Basic.pptx
HTML-Basic.pptxHTML-Basic.pptx
HTML-Basic.pptx
 
UNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptxUNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptx
 
UNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptxUNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptx
 
UNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptxUNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptx
 
page_fault pbm.ppt
page_fault pbm.pptpage_fault pbm.ppt
page_fault pbm.ppt
 
process syn.ppt
process syn.pptprocess syn.ppt
process syn.ppt
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
selinuxbasicusage.pptx
selinuxbasicusage.pptxselinuxbasicusage.pptx
selinuxbasicusage.pptx
 
lvm.pptx
lvm.pptxlvm.pptx
lvm.pptx
 
SSH.ppt
SSH.pptSSH.ppt
SSH.ppt
 
environmentalpollution-.pptx
environmentalpollution-.pptxenvironmentalpollution-.pptx
environmentalpollution-.pptx
 
DM.pptx
DM.pptxDM.pptx
DM.pptx
 
thermal pollution.pptx
thermal pollution.pptxthermal pollution.pptx
thermal pollution.pptx
 
marinepollution.pptx
marinepollution.pptxmarinepollution.pptx
marinepollution.pptx
 
logical volume manager.ppt
logical volume manager.pptlogical volume manager.ppt
logical volume manager.ppt
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
c-c++-java-python programs.docx
c-c++-java-python programs.docxc-c++-java-python programs.docx
c-c++-java-python programs.docx
 

Dernier

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 

Dernier (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

12

  • 1. INDEX S.NO DATE TOPIC PAGE NO STAFF SIGNATURE 1 DISTANCE CONVERSION PROBLEM 1 2 OVERLOADING OBJECTS 10 3 OVERLOADING CONVERSIONS 16 4 OVRELOADING MATRIX 22 5 AREA COMPUTATION USING DERIVED CLASS 32 6 VECTOR PROBLEM 37 7 INHERITANCE 43
  • 2. EX.NO:1 DATE: DISTANCE CONVERSION PROBLEM AIM: Create two classes DM and DB which store the value of distances. DM store the value ofdistances. DM stores distances in meters and centimeters in DB in feet and inches. Write a Programthat can create the values of the class objects and add one object DM with another object DB. Use a friend function to carry out addition operation. The object that stores the result may be DM object or DB objectdepending on the units in which results are required. The display should be in the order of meter and centimeter and feet or inches depending on the order of display. ALGORITHM: STEP 1: Start the program execution. STEP 2: To create a class metric and british. STEP 3: To create a function input() and display(). STEP 4: Accept the feet,inches value of british. STEP 5: Accept the meter ,cm,value of metric. STEP 6: To convert metric value to british value.
  • 3. STEP 7: To convert british value to metric value. STEP 8: To display the metric values and british values. STEP 9: Stop the program execution. CODING: #include<iostream.h> #include<conio.h> #include<math.h> class metric; class british { public: int feet,inches; void input(); friend british addbritish(british & b,metric & m); void display(); }; class metric { public: int meter,cm;
  • 4. void input(); friend metric addmetric(metric & m,british & b); void display(); }; void british::input() { cout<<"nt enter the value of feet:"; cin>>feet; cout<<"nt enter the value of inches:"; cin>>inches; } british addbritish(british & b,metric & m) { british b1; int ftin,tmcm,tin,mtcm,tm,cm,tmcmtin,tot; ftin=(b.feet)*12; tin=ftin+b.inches; mtcm=(m.meter)*100; tmcm=mtcm+m.cm; tmcmtin=tmcm/2.5; tot=tin+tmcmtin; b1.feet=tot/12; b1.inches=tot%12; return(b1); }
  • 5. void british::display() { cout<<"nt the feet value is:t"<<feet; cout<<"nt the inches value is:t"<<inches; } void metric::input() { cout<<"nt enter the value of meter:t"; cin>>meter; cout<<"nt enter the value of cm:t"; cin>>cm; } metric addmetric(metric & m,british & b) { metric m1; int tin,ftin,mtcm,tincmt,tot; ftin=(b.feet)*12; tincmt=(ftin+b.inches)*2.5; mtcm=(m.meter)*100; tot=tincmt+mtcm+m.cm; m1.meter=tot/100; m1.cm=tot%100; return(m1); } void metric::display()
  • 6. { cout<<"nt the meter value is t"<<meter; cout<<"nt the centimeter value is t"<<cm; } void main() { int op; clrscr(); british b1,b2; metric m1,m2; cout<<"nDistance conversion"; b1.input(); m1.input(); do { clrscr(); cout<<"nMENU"; cout<<"n1.Metric to British"; cout<<"n2.British to Metric"; cout<<"n3.Exit"; cout<<"nEnter the choice:"; cin>>op; switch(op) { case 1:
  • 7. cout<<"nt metric to british"; cout<<"nt output"; b1.display(); m1.display(); b2=addbritish(b1,m1); cout<<"nt output"; b2.display(); break; case 2: cout<<"nt british to metric"; cout<<"nt output"; b1.display(); m1.display(); m2=addmetric(m1,b1); cout<<"noutput"; m2.display(); break; case 3: cout<<"nexit"; break; } getch(); } while (op!=3); }
  • 8. OUTPUT Distance conversion enter the value of feet: 10 enter the value of inches: 6 enter the value of meter: 4 enter the value of cm: 2 MENU 1.Metric to British 2.Britishto Metric 3.Exit Enter the choice:1 metric to british output the feetvalue is: 10 the inches value is: 6 the meter value is 4 the centimetervalue is 2 output the feetvalue is: 23 the inches value is: 10 MENU 1.Metric to British
  • 9. 2.Britishto Metric 3.Exit Enter the choice:2 british to metric output the feetvalue is: 10 the inches value is: 6 the meter value is 4 the centimetervalue is 2 output the meter value is 7 the centimetervalue is 17 MENU 1.Metric to British 2.Britishto Metric 3.Exit Enter the choice:3 Exit RESULT
  • 10. EX.NO:2 DATE: OVERLOADING OBJECTS AIM: Create a class FLOAT that contains one float data member overload all the four arithmetic operators so that operate on the objects of FLOAT. ALGORITHM : STEP 1: Start the program execution STEP 2: To create a class FLOAT STEP 3: Accept the input values STEP 4: Overloadthe arithmetic operator+ STEP 5: Overloadthe arithmetic operetor– STEP 6: Overloadthe arithmetic operator* STEP 7: Overloadthe arithmetic operator/
  • 11. STEP 8: To display the output values. STEP 9: Stop the program execution. CODING: #include<iostream.h> #include<conio.h> #include<math.h> class FLOAT { float x,D; public: FLOAT() { } FLOAT(float a) { x=a; } FLOAT operator+(FLOAT); FLOAT operator-(FLOAT); FLOAT operator*(FLOAT);
  • 12. FLOAT operator/(FLOAT); void outdata(); void indata() { cout<<"nnt enter the value:"; cin>>x; } }; FLOAT FLOAT::operator+(FLOAT D) { FLOAT temp; temp.x=x+D.x; return(temp); } FLOAT FLOAT::operator-(FLOAT D) { FLOAT temp; temp.x=x-D.x; return(temp); } FLOAT FLOAT::operator*(FLOAT D) { FLOAT temp; temp.x=x*D.x; return(temp);
  • 13. } FLOAT FLOAT::operator/(FLOAT D) { FLOAT temp; temp.x=x/D.x; return(temp); } void FLOAT::outdata(void) { cout<<x<<endl; } int main() { FLOAT o1,o2,ADD,SUB,MUL,DIV; clrscr(); o1.indata(); o2.indata(); ADD=o1+o2; SUB=o1-o2; MUL=o1*o2; DIV=o1/o2; cout<<"nnt o1:"; o1.outdata(); cout<<"nnt o2:"; o2.outdata();
  • 14. cout<<"nnt ADDITION VALUE IS (o1+o2)="; ADD.outdata(); cout<<"nnt SUBTRACTION VALUE IS (o1-o2)="; SUB.outdata(); cout<<"nnt MULTIPLICATION VALUE IS (o1*o2)="; MUL.outdata(); cout<<"nnt DIVISION VALUE IS (o1/o2)="; DIV.outdata(); getch(); return(0); }
  • 15. 2.OUTPUT: enter the value:4 enter the value:4 o1:4 o2:4 ADDITION VALUE IS (o1+o2)=8 SUBTRACTION VALUE IS (o1-o2)=0 MULTIPLICATION VALUE IS (o1*o2)=16 DIVISION VALUE IS (o1/o2)=1 RESULT:
  • 16. EX.NO:3 DATE: OVERLOADING CONVERSIONS: AIM: Designa class polarwhich describes a point in a plane using polar Co-ordinates radius and angle. A point in polar Co-ordinates is as shown below. Use the overloader+ operatorto add two objects of polar. Note that we cannot add polar values of two points directly. This requires first the conversion. Points into rectangular Co-ordinates and finally converting the result into polar Co-ordinates. You need to use following trigonometric formulas. X= r * cos (a); Y= r * sin (a); a= sqrt (X * X +Y * Y); ALGORITHM : STEP 1: Start the program execution. STEP 2: To create class polar. STEP 3: Accept the radius and angle values. STEP 4: First we acceptthe radius and angle value is 0.
  • 17. STEP 5: To create arguments in polar. STEP 6: To overload the + operatorto add two object of polar. STEP 7: To display the output values. STEP 8: Stop the program execution. CODING: #include<iostream.h> #include<conio.h> #include<math.h> class polar { double radius,angle; public: polar() { radius=0; angle=0; }
  • 18. polar(double r,double a) { radius=r; angle=a; } void disp(); polar operator+(polar); }; void polar::disp() { cout<<"nnt radius value is:"; cout<<radius; cout<<"nnt angle value is:"; cout<<angle; } polar polar::operator+(polar p1) { polar p2; double x1,x2,y1,y2,x,y; x1=radius*cos(angle*3.14/180); x2=p1.radius*cos(p1.angle*3.14/180); y1=radius*sin(angle*3.14/180); y2=p1.radius*sin(p1.angle*3.14/180);
  • 19. cout<<"noutputn"; cout<<"*****n"; cout<<"nn radius 1="<<x1<<"tangle 1="<<y1; cout<<"nn radius 2="<<x2<<"tangle 2="<<y2; x=x1+x2; y=y1=y2; cout<<"nn sum of the radius in rectangularcoordinates is:"; cout<<x; cout<<"nn sum of the angle in rectangularcoordinates is:"; cout<<y; p2.radius=sqrt(x*x+y*y); p2.angle=atan(y/x)*(180/3.14); return(p2); } void main() { clrscr(); cout.precision(2); polar o1,o2,o3; double r1,r2,a1,a2; char c; do {
  • 20. cout<<"nenter the radius 1 and angle 1:"; cin>>r1>>a1; cout<<"nenter the radius 2 and angle 2:"; cin>>r2>>a2; o1=polar(r1,a1); o2=polar(r2,a2); o3=o1+o2; o3.disp(); cout<<"nn Do you want to continue(y/n):"; cin>>c; } while(c=='y'||c!='n'); getch(); }
  • 21. 3.OUTPUT enter the radius 1 and angle 1: 11 13 enter the radius 2 and angle 2: 13 15 output ***** radius 1=10.72 angle 1=2.47 radius 2=12.56 angle 2=3.36 sum of the radius in rectangularcoordinates is:23.28 sum of the angle in rectangularcoordinates is:3.36 radius value is:23.52 angle value is:8.23 Do you want to continue(y/n):n RESULT:
  • 22. EX.NO:4 DATE: OVRELOADING MATRIX: AIM: Create a class MAT of size M*N. Define all possible matrix operations for MAT type objects. Verify the identity. (A-B)^2 = A^2+B^2 –2*A*B ALGORITHM : STEP 1: Start the program execution. STEP 2: To create a class MAT. STEP 3: To acceptthe elementof matrices. STEP 4: To create a function inp(int) and disp(). STEP 5: To overload the operatorthe operators +,-,*,/,^. STEP 6: To using for condition.
  • 23. STEP 7: To acceptthe elementof first and secondmatrix. STEP 8: To calculate (A-B)^2. STEP 9: To calculate A^2+B^2-2*A*B. STEP 10: To verify (A-B)^2=A^2+B^2-2AB the identity is true using it condition. STEP 11: To verify (A-B)^2!=A^2+B^2-2AB the given identity is false. STEP 12: To create a output values. STEP 13: Stop the program execution. CODING: #include<iostream.h> #include<conio.h> #include<math.h> constsize=3; class mat { int nrc;
  • 24. int a[size][size]; public: void inp(int); void disp(); mat operator+(mat); mat operator-(mat); mat operator*(mat); mat operator*(int); mat operator^(int); int operator==(mat); }; void mat::inp(int n) { nrc=n; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) cin>>a[i][j]; } void mat::disp() { for(int i=0;i<nrc;i++) { for(int j=0;j<nrc;j++)
  • 25. cout<<a[i][j]<<" "; cout<<endl; } } mat mat::operator+(mat m) { mat temp; temp.nrc=nrc; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) temp.a[i][j]=a[i][j]+m.a[i][j]; return temp; } mat mat::operator-(mat m) { mat temp; temp.nrc=nrc; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) temp.a[i][j]=a[i][j]-m.a[i][j]; return temp; } mat mat::operator*(mat m)
  • 26. { mat temp; temp.nrc=nrc; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) { temp.a[i][j]=0; for(int k=0;k<nrc;k++) temp.a[i][j]+=a[i][j]*m.a[i][j]; } return temp; } mat mat::operator*(int x) { mat temp; temp.nrc=nrc; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) temp.a[i][j]=x*a[i][j]; return temp; } mat mat::operator^(int) {
  • 27. mat temp; temp.nrc=nrc; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) { temp.a[i][j]=0; for(int k=0;k<nrc;k++) temp.a[i][j]+=a[i][j]*a[i][j]; } return temp; } int mat::operator==(mat m) { int t=1; int f=0; for(int i=0;i<nrc;i++) for(int j=0;j<nrc;j++) if(a[i][j]!=m.a[i][j]) return f; else return t; return 0; }
  • 28. void main() { clrscr(); mat m1,m2,mat1,mat2; int n; cout<<"nenter the order of matrices:"; cin>>n; cout<<"nenter the element of first matrix:"; m1.inp(n); cout<<"nenter the element of secondmatrix:"; m2.inp(n); cout<<"nfirst matrix is:"; m1.disp(); cout<<"nsecondmatrix is:"; m2.disp(); mat1=(m1-m2)^2; cout<<"nresult of (A-B)^2 is:n"; mat1.disp(); mat2=(m1^2)+(m2^2)-((m1*m2)*2); cout<<"nresult of (A^2+B^2-2AB)is:n"; mat2.disp(); if(mat1==mat2) cout<<"nthe given identity is true:n";
  • 29. else cout<<"nthe given identity is false:n"; getch(); }
  • 30. 4.OUTPUT: enter the order of matrices:2 enter the element of first matrix: 1 1 1 1 enter the element of secondmatrix: 1 1 1 1 first matrix is: 1 1 1 1 secondmatrix is: 1 1 1 1 result of (A-B)^2 is: 0 0 0 0
  • 31. result of (A^2+B^2-2AB)is: 0 0 0 0 the given identity is true: RESULT:
  • 32. EX.NO:5 DATE: AREA COMPUTATION USING DERIVED CLASS AIM: Area of rectangle = X*Y Area of triangle = ½ * X * Y ALGORITHM : STEP 1: Start the program execution. STEP 2: To create a class rectangle andtriangle. STEP 3: Create a function get(),cal()and disp(). STEP 4: Accept the two sides of rectangles and triangle. STEP 5: Calculate the area of rectangle are=X*Y. STEP 5: Calculate the area of triangle are =1/2*X*Y. STEP 6: Display the outputs.
  • 33. STEP 7: Stop the program execution. CODING #include<iostream.h> #include<conio.h> #include<math.h> class rectangle { float area; protected: float x,y; public: void get(); void calc() { area=x*y; } void disp(); }; void rectangle::get() {
  • 34. cout<<"nenter the sides of rectangle and triangle:"; cin>>x>>y; } void rectangle::disp() { cout<<"narea of the rectangle is:"<<area<<endl; } class triangle:public rectangle { float area; public: void calc() { area=(x*y)/2; } void disp() { cout<<"narea of the triangle is:"<<area; } }; void main() { clrscr();
  • 36. 5.OUTPUT: enter the sides of rectangle and triangle: 4 5 area of the rectangle is:20 area of the triangle is:10 RESULT:
  • 37. EX.NO:6 DATE: VECTOR PROBLEM: AIM: Define a class forvector containing scalarvalues. Apply overloading concepts for vectoraddition, Multiplication of a vectorby a scalarquantity, replace the values in a position vector. ALGORITHM STEP 1: Start the program execution. STEP 2: To create a class vector. STEP 3: To acceptthe input values. STEP 4: Overloading the *,+,<<,>>operators. STEP 5: To multiply the vector values. STEP 6: To calculate the sum of two vectors.
  • 38. STEP 7: To change the position of elements to be modified vector. STEP 8: To acceptthe input values. STEP 9: To display the output values. STEP 10: Stop the program execution. CODING: #include<iostream.h> #include<conio.h> #include<math.h> constsize=3; class vector { public: int *v; vector() { v=new int[size]; } int & operator[](int);
  • 39. friend vector operator*(int,vector); friend vector operator+(vector,vector); friend istream & operator>>(istream&,vector&); friend ostream& operator>>(ostream&,vector&); }; int &vector::operator[](int pos) { return v[pos]; } vectoroperator * (int a,vectorb) { vectorc; for(int i=0;i<size;i++) c.v[i]=a*b.v[i]; return c; } vectoroperator+(vectora,vectorb) { vectorc; for(int i=0;i<size;i++) c.v[i]=a.v[i]+b.v[i]; return c; }
  • 40. istream & operator>>(istream&cin,vector&b) { for(int i=0;i<size;i++) cin>>b.v[i]; return cin; } ostream&operator<<(ostream&cout,vector&b) { cout<<","<<b.v[0]; for(int i=1;i<size;i++) { cout<<","<<b.v[i]; } return cout; } void main() { clrscr(); vectorm,n; int sc; cout<<"nenter the elementof vector1:"; cin>>m; cout<<"nenter the elementof vector2:";
  • 41. cin>>n; cout<<"noutput"; cout<<"n****************"; cout<<"nvector1_"<<m; cout<<"nvector2_"<<n; vectorsum,mul; cout<<"nscalarmultiplication value:"; cin>>sc; mul=sc * m; sum=m+n; cout<<"nscalarmultiplication of vector 1 is:"<<mul; cout<<"nsum of the two vector is :"<<sum; int pos,nval; cout<<"nenter the positionof the element to be modified (vector):"; cin>>pos; cout<<"nnenter the value:"; cin>>nval; m[pos-1]=nval; cout<<"nnmodified value is:"<<m; getch(); }
  • 42. 6.OUTPUT enter the element of vector 1: 5 6 4 enter the element of vector 2: 4 8 6 output **************** vector1:5,6,4 vector2:4,8,6 scalarmultiplication value:3 scalarmultiplication of vector1 is: 15,18,12 sum of the two vectoris : 9,14,10 enter the position of the element to be modified (vector):2 enter the value:5 modified value is:5,5,4 RESULT:
  • 43. EX.NO:7 DATE: INHERITANCE AIM: Create three classes alpha, beta and gamma, eachcontaining one data member. The class gamma should be inherited from both alpha and beta. Use a constructorfunction in the class gamma to assignvalues to the data members of all the classes. ALGORITHM: STEP 1: Start the program execution. STEP 2: To create a three classes alpha, beta and gamma STEP 3: To acceptthe input values. STEP 4: TO use constructorfunction STEP 5: To acceptthe input values. STEP 6: To display the output values. STEP 7: Stop the program execution.
  • 44. CODING: #include<iostream.h> #include<conio.h> #include<math.h> class alpha { int x; public: alpha(int i) { x=i; cout<<"alpha intialisedn"; } void show_x(void) { cout<<"x="<<x<<"n"; } }; class beta { float y; public:
  • 45. beta(floatj) { y=j; cout<<"beta initializedn"; } void show_y(void) { cout<<"y="<<y<<"n"; } }; class gamma:public beta,public alpha { int m,n; public: gamma(int a,floatb,int c,int d):alpha(a),beta(b) { m=c; n=d; cout<<"gamma initializedn"; } void show_mn(void) { cout<<"m="<<m<<"n";
  • 47. 7.OUTPUT beta initialized alpha intialised gamma initialized x=5 y=10.75 m=20 n=30 RESULT: