3. res=3.141*r*r;
cout<<"Area of Circle: "<<res<<endl;
}
float area(float l,float b)
{
float ress;
ress=l*b;
cout<<"Area of Rectangle Box:"<<ress<<endl;
}
};
int main()
{
float b,h,r,l;
float result;
Shape call;
cout<<"Enter the Base"<<endl;
cin>>b;
cout<<"Enter the Hieght"<<endl;
cin>>h;
call.area(b,h);
cout<<"Enter the Radius of Circle: "<<endl;
cin>>r;
call.area(r);
cout<<"Enter the Length:"<<endl;
cin>>l;
cout<<"Enter the Bredth:"<<endl;
cin>>b;
call.area(l,b);
return 0;
}
Question=-05
#include<iostream>
#include<conio.h>
using namespace std;
class hospital
{
int rooms,bed,days,pationt;
float per_day;
public:
void set(int rm, int be, int da, int pat,float perd)
{
rooms=rm;
bed=be;
days=da;
pationt=pat;
per_day=perd;
}
void geter()
{
cout<<"Total Room is:"<<rooms<<endl;
cout<<"Total bed is:"<<bed<<endl;
cout<<"Total days:"<<days<<endl;
cout<<"total pationt:"<<pationt<<endl;
cout<<"Pationt charges"<<per_day<<endl;
}
void bedallotment()
{
int bdal;
bdal=(rooms*bed)-pationt;
cout<<"Total number of the bed is:"<<bdal;
}
4. };
int main()
{
int ro, b,d,p;
float perd;
hospital call;
cout<<"Enter the room :"<<endl;
cin>>ro;
cout<<"Enter the bed :"<<endl;
cin>>b;
cout<<"Enter the days :"<<endl;
cin>>d;
cout<<"Enter the pationt :"<<endl;
cin>>p;
cout<<"Enter the perday charges :"<<endl;
cin>>perd;
call.set(ro,b,d,p,perd);
call.geter();
call.bedallotment();
return 0;
}
Question-06
#include<iostream>
using namespace std;
class rectangle
{
private:
float width,i,j;
int length;
public:
void setwid(float wid)
{
width=wid;
}
void setlen(int len)
{
length=len;
}
float area()
{
float i;
i=length*width;
return i;
}
float pirem()
{
float j;
j= 2*length*2 *width;
return j;
}
int same(rectangle te)
{
if(i==te.i)
{
cout<<"Same type"<<endl;
return 1;
}
else
{
cout<<"Not same"<<endl;
5. return 0;
}
}
};
int main()
{
float area,pirem,are,pir;
int rectangl;
rectangle call,call1;
call.setwid(2.5);
call.setlen(5);
call1.setwid(18.9);
call1.setlen(5);
area=call.area();
pirem=call.pirem();
cout<<"Area is:"<<area<<endl<<"n";
cout<<"Perimeters is:"<<pirem<<endl<<"n";;
are=call1.area();
pir=call1.pirem();
cout<<"Second Area is:"<<are<<endl<<"n";;
cout<<"Second Piremeters is :"<<pir<<endl<<"n";;
rectangl=call.same(call1);
cout<<rectangl<<endl;
return 0;
}
Question-07
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class batsman
{
private:
string bcode;
string bname;
int innings, notout, runs;
public:
void readdata(string bde, string nme, int ings,int nt,int rn)
{
bname=nme;
bcode=bde;
innings=ings;
notout=nt;
runs=rn;
}
void displaydata()
{
cout<<"Bats Name is:"<<bname<<endl;
cout<<"Innings is:"<<innings<<endl;
cout<<"Not out is:"<<notout<<endl;
cout<<"Runs is:"<<runs<<endl;
}
void calavg()
{
float batavg;
batavg =runs/(innings-notout);
cout<<"Avg Is :"<<batavg<<endl;
}
6. };
int main()
{
string na,bco;
int in,no,rns;
cout<<"Enter the Bats Man Name:"<<endl;
cin>>na;
cout<<"Enter the Bats Man Code:"<<endl;
cin>>bco;
cout<<"Enter the Innings :"<<endl;
cin>>in;
cout<<"Enter the Notout:"<<endl;
cin>>no;
cout<<"Enter the runs :"<<endl;
cin>>rns;
batsman call;
call.readdata(na,bco,in,no,rns);
call.displaydata();
call.calavg();
return 0;
}
Question-08
#include<iostream>
#include<conio.h>
using namespace std;
class complex1;
class complex{
private:
int x,y;
public:
complex()
{
}
void in()
{
cout<<"Enter real number";
cin>>x;
cout<<"Enter an imaginary number";
cin>>y;
}
void show()
{
cout<<"n1st complex numbern";
cout<<x<<"+"<<y<<"i"<<"n";
}
friend void show2(complex,complex1);
};
class complex1
{
private:
int m,n;
public:
complex1()
{
}
void input()
{
cout<<"nEnter 2nd complex numbern";
cout<<"Enter real number";
cin>>m;
cout<<"Enter an imaginary number";
cin>>n;
}
7. void show1()
{
cout<<"n2nd complex numbern";
cout<<m<<"+"<<n<<"i";
}
friend void show2(complex,complex1);
};
void show2(complex c, complex1 d )
{
int img,real;
real=c.x+d.m;
img=c.y+d.n;
cout<<"sum of complex numbern";
cout<<real<<"+"<<img<<"i";
}
int main()
{
complex obj1;
complex1 obj2;
obj1.in();
obj2.input();
obj1.show();
obj2.show1();
show2(obj1,obj2);
_getch();
}
Question-10
#include<iostream>
#include<conio.h>
using namespace std;
class complex1;
class complex{
private:
int x,y;
public:
complex()
{
}
void in()
{
cout<<"Enter real number";
cin>>x;
cout<<"Enter an imaginary number";
cin>>y;
}
void show()
{
cout<<"n1st complex numbern";
cout<<x<<"+"<<y<<"i"<<"n";
}
friend void show2(complex,complex1);
};
class complex1
{
private:
int m,n;
public:
complex1()
{
}
void input()
{
8. cout<<"nEnter 2nd complex numbern";
cout<<"Enter real number";
cin>>m;
cout<<"Enter an imaginary number";
cin>>n;
}
void show1()
{
cout<<"n2nd complex numbern";
cout<<m<<"+"<<n<<"i";
}
friend void show2(complex,complex1);
};
void show2(complex c, complex1 d )
{
int img,real;
real=c.x+d.m;
img=c.y+d.n;
cout<<"sum of complex numbern";
cout<<real<<"+"<<img<<"i";
}
int main()
{
complex obj1;
complex1 obj2;
obj1.in();
obj2.input();
obj1.show();
obj2.show1();
show2(obj1,obj2);
_getch();
}