0% found this document useful (0 votes)
15 views3 pages

Practical

Uploaded by

abdulanish20004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Practical

Uploaded by

abdulanish20004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PARAMETRIZED CONSTRUC:OR

#include<iostream.h>
#include<conio.h>
class compleex

float X, Yi
publ iC:
Complex ()
Complex(float real,float img)
X=real
y=img
Complex operator (complex);
void dy ();

Complex complex::operator (complex C)


Complex tenp;
temp.X=X+C. X;
temp.y=y+C.y
return temp;

void compleX: dy()

cout<<x<<"+ i"<<y<<endl;
VOid main ()

Clrscr);
Complex c1, c2, c3;
clcomplex (2.5,3.5);
c2=complex (1.5,2.5)
c3 cl+ C2;
cout<"c1="; Cl.dy();
cout<<" c2="; c2.dy(
Cout<<"c3="; c3.dy():
getch ()

OUT PUT:
cl 2.5+i3.5
c2=1.5+i2.5
c3-4+i6
#include<iostream.h>
#include<conio.h>
class student

publ iC:
char name 20 ,
fnanel[20), age[10];
Class address:
public st udent
public
char st.reet
[ 20i,city[201,pincode [7]1
vo1d input. )

COut<<"enter the name: \n";


Cin>>name;
Cout<<"enter the fname: \n";
Cin>>fname;
COut<<"enter the age: \n";
Cin>age;
Cout<<"enter the street: \n";
Cin>>street
Cout<<"enter the cit.y: \n"
Cin>>city; base ct
Cout<<"enter the pincode: \n";
Cin>>pincode; Student
void display()

cout<<"\n Name: "<<name;


cout <<" \n Fname:
cout<<"\n Age: "<<age;
"<<fname; address
Cout<<" \n St. reet: "<<street;
cout<<" \n City: "<<City;
dervedd cas6
Cout<<"\n Pi ncode:
"<<pincode;
class
details:publ ic student addreSS:PubIrc Studant,
publiC:
char Course
20, college[20];
detaiis: publfe Seudant.
void get data(

Cout< "enter the course:


\n";
cin>>course;
cout<< "enter the college: n":
cin>>college;
void di splay(

Cout<<" \n Course:"<<course;
cout<"\n College: "<<college:

void main()

clrscr ()
address al;
details dl;
al.input )
dl.getdata()
clrscr ()
al.display()
FUNCT ION OVERLOADING

#1ncludeci0stream.h>

#include<conic.h>

class over

publicC:
int area (int 1,int br);
float àrea(float b, float h);
double area(double r)

int over: :area (int 1, int br)

int arec;
arec-l *br;
return(areC);

float over:: area ( float b, float h)

float atri;
atri=0.5*b*h;
return (atri)

double over: :area( double r)

double asphere;
asphere=1.3333.14*r'r*r;
return (asphe re);

vOid main

Over p;
int 1,br:
float b, h;
double r;
Cirscr);
cout<<"RECTANGLE \n";
cout<<"enter t he value for l and br: ";
cin>>l>>br;
cout<<"\narea of rectangle="<<p. area ( 1, br);
Cout<< "\n";
Cout< "TRIANGIE\n";
cout<<"enter t he value for b and h: "
Cin>>b>>h;
cout <<"\narea of triangle="<<p.area (b, h)
Cout<<" \n";
Cout< "SPHERE\n";
cout< "enter the value for r:";
Cin>>r;
cout<<"\narea of sphere="<<p.area (r)
cout<< "\n";
getch()

OUTPUT:
RECTANGI.E
enter the value for 1 and br:4 8
area of rectangle- 32 4
TRIANGLE
enter the value for b and h:6 5 5
area of triangle=15 5
SPHERE
enter the value for r:7
area of sphere-1435.66766
a04O1392

You might also like