Oop lab report
Upcoming SlideShare
Loading in...5
×
 

Oop lab report

on

  • 1,065 views

 

Statistics

Views

Total Views
1,065
Views on SlideShare
1,065
Embed Views
0

Actions

Likes
1
Downloads
42
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Oop lab report Oop lab report Document Transcript

  • Comsats University of Science and Technology Islamabad LAB WORK 4Name: Muhammad TahirRoll No: Sp11-Bcs-107Subject: Object Oriented Programming (Oop)Section: 3ASubmitted To: Mam NusratShaheen Date:27/03/2012
  • Program No:01#include<iostream>#include<conio.h>using namespace std;class book{private:int page;float price;string title;public:voidgetvalue() {cout<<"Enter pages"<<endl;cin>>page;cout<<"Enter price"<<endl;cin>>price;cout<<"Enter title"<<endl;cin>>title; }void display() {cout<<"Pages are= "<<page<<endl;cout<<"Price are="<<price<<endl;cout<<"Title is="<<title<<endl; }
  • };main(){book b1,b2,b3;b1.getvalue();b2.getvalue();b3.getvalue();book b3=b1;b1.display();b2.display();b3.display();getch();return 0;} Program No: 02#include<iostream>#include<conio.h>using namespace std;class book{private:int page;float price;string title;public:voidgetvalue()
  • {cout<<"Enter pages"<<endl;cin>>page;cout<<"Enter price"<<endl;cin>>price;cout<<"Enter title"<<endl;cin>>title; }voidsetvalue() { cout<<"Enter pages"<<endl;cin>>page;cout<<"Enter price"<<endl;cin>>price;cout<<"Enter title"<<endl;cin>>title; }void display() {cout<<"Pages are= "<<page<<endl;cout<<"Price are="<<price<<endl;cout<<"Title is="<<title<<endl; }};main(){book b1,b2,b3;
  • b1.getvalue();b2.getvalue();b3.getvalue(); b3=b1;b1.display();b2.display();b3.display();b3.setvalue();b1.display();b2.display();b3.display();getch();return 0;} Program No: 03#include<iostream>#include<conio.h>using namespace std;class travel{private:float km;int h;public:travel():km(0),h(0) {
  • }voidgetvalue() {cout<<"Enter kilometer"<<endl;cin>>km;cout<<"Enter hour"<<endl;cin>>h; }void show() {cout<<"Values are="<<km<<endl;cout<<"Values are="<<h<<ebdl; }void add(t1,t2) {float sum=0;sum=t1+t2;cout<<sum; }};main(){travel t1,t2,t3;t1.getvalue();t1.show();t2.getvalue();
  • t2.show();t3.add(t1,t2);getch();return 0;} Program No: 04#include<iostream>#include<conio.h>using namespace std;class time{private:inthour,min,sec;public:time():km(0),h(0) { }voidgetvalue() {cout<<"Enter hours"<<endl;cin>>hour;cout<<"Enter minute"<<endl;cin>>min;cout<<"Enter second"<<endl;cin>>sec; }
  • void show() {cout<<"Hours ="<<hour<<endl;cout<<"Minute ="<<min<<endl;cout<<"Second ="<<sec<<endl; }void add(hour,min,sec) {int sum=0;sum=hour+min+sec;cout<<"Addition of hours, minute and second is="<<sum; }};main(){travelh,m,s,su;h.getvalue();h.show();m.getvalue();m.show();s.getvalue();s.show();su.add(h,m,s);getch();return 0;}
  • Program No: 05#include<iostream.h>#include<conio.h>classcountr{private:int count;public:countr(){count=0;}voidincr(){count++;}void display(){cout<<count;}};void main(){clrscr();countr c1;c1.incr();c1.display();c1.incr();c1.display();getch();} Program No: 06#include<iostream.h> #include<conio.h>class student{
  • private:staticint a;public:static void roll(int);static void showroll();};int student::a=157;void student::roll(int roll){ a=roll;}void student::showroll(){cout<<"roll number is: "<<a<<"n";}void main(){clrscr(); student::roll(10); student::showroll(); student::roll(11); student::showroll(); student::roll(12); student::showroll();getch();}