Question-01
#include<iostream>
using namespace std;
class Citizen
{
private:
string name;
string nationality;
public:
Citizen()
{
}
Citizen(string n,string na)
{
name=n;
nationality=na;
}
void display()
{
cout<<"Name is: "<<name<<endl;
cout<<"Nationality is: "<<nationality<<endl;
}
~Citizen()
{
cout<<"distructor is called"<<endl;
}
};
main()
{
Citizen call1("usman","Pakistan");
Citizen call2=call1;
Citizen call3=call1;
call1.display();
call2.display();
cout<<" "<<endl;
call3.display();
return 0;
}
Question-02
#include <iostream>
#include<string>
using namespace std;
class Time
{
private:
int hour,minute,second;
public:
void get()
{
cout<<"Enter the hours: "<<endl;
cin>>hour;
cout<<"Enter the minutes: "<<endl;
cin>>minute;
cout<<"Enter the seconds: "<<endl;
cin>>second;
}
void show()
{
cout<<"Time is: n ";
cout<<hour<<":"<<minute<<":"<<second;
}
Time sum(Time a)
{
Time res;
res.hour=a.hour+hour;
res.minute=a.minute+minute;
res.second=a.second+second;
return res;
}
};
int main()
{
Time tim,tim2,tim3;
tim.get();
tim2.get();
tim3=tim.sum(tim2);
tim3.show();
return 0;
}
Question-03
#include<iostream>
#include<conio.h>
using namespace std;
class Box
{
private:
float length,breadth,height;
public:
Box(float l,float b, float h)
{
length=l;
breadth=b;
height=h;
}
void display()
{
cout<<"Length:"<<length<<endl;
cout<<"Breadth:"<<breadth<<endl;
cout<<"Height:"<<height<<endl;
}
};
int main()
{
Box call(25.4,45.2,20.22);
call.display();
return 0;
}
Question-04
#include<iostream>
#include<conio.h>
using namespace std;
class Shape
{
public:
void area(float n,float b,float r)
{
float ar;
ar=0.5*3.141*r;
cout<<"Area of rectangle is:"<<ar<<endl;
}
float area(float r)
{
float res;
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;
}
};
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;
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;
}
};
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;
}
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()
{
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();
}

Oopppp

  • 1.
    Question-01 #include<iostream> using namespace std; classCitizen { private: string name; string nationality; public: Citizen() { } Citizen(string n,string na) { name=n; nationality=na; } void display() { cout<<"Name is: "<<name<<endl; cout<<"Nationality is: "<<nationality<<endl; } ~Citizen() { cout<<"distructor is called"<<endl; } }; main() { Citizen call1("usman","Pakistan"); Citizen call2=call1; Citizen call3=call1; call1.display(); call2.display(); cout<<" "<<endl; call3.display(); return 0; } Question-02 #include <iostream> #include<string> using namespace std; class Time { private: int hour,minute,second; public: void get() { cout<<"Enter the hours: "<<endl; cin>>hour; cout<<"Enter the minutes: "<<endl; cin>>minute; cout<<"Enter the seconds: "<<endl; cin>>second; } void show() { cout<<"Time is: n "; cout<<hour<<":"<<minute<<":"<<second; } Time sum(Time a)
  • 2.
    { Time res; res.hour=a.hour+hour; res.minute=a.minute+minute; res.second=a.second+second; return res; } }; intmain() { Time tim,tim2,tim3; tim.get(); tim2.get(); tim3=tim.sum(tim2); tim3.show(); return 0; } Question-03 #include<iostream> #include<conio.h> using namespace std; class Box { private: float length,breadth,height; public: Box(float l,float b, float h) { length=l; breadth=b; height=h; } void display() { cout<<"Length:"<<length<<endl; cout<<"Breadth:"<<breadth<<endl; cout<<"Height:"<<height<<endl; } }; int main() { Box call(25.4,45.2,20.22); call.display(); return 0; } Question-04 #include<iostream> #include<conio.h> using namespace std; class Shape { public: void area(float n,float b,float r) { float ar; ar=0.5*3.141*r; cout<<"Area of rectangle is:"<<ar<<endl; } float area(float r) { float res;
  • 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() { floatarea,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; intin,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 complexnumbern"; 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 complexnumbern"; 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(); }