SlideShare a Scribd company logo
Comsats University of Science and Technology Islamabad


                              LAB WORK 4

Name:
           Muhammad Tahir
Roll No:
           Sp11-Bcs-107
Subject:
           Object Oriented Programming (Oop)
Section:
           3A
Submitted 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();}

More Related Content

PDF
C++ programs
DOCX
Basic Programs of C++
PPTX
C- Programs - Harsh
DOCX
Class array
TXT
Penjualan swalayan
DOCX
Include
C++ programs
Basic Programs of C++
C- Programs - Harsh
Class array
Penjualan swalayan
Include

What's hot (20)

DOCX
Pratik Bakane C++
DOC
Pads lab manual final
PDF
Javascript & Ajax Basics
DOCX
C++ file
PPTX
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
DOCX
Assignement of programming & problem solving
PPT
Cpp tutorial
PDF
Un dsl pour ma base de données
PPTX
Dex and Uniswap
PPTX
Solidity
PPTX
PDF
C++ Programming - 3rd Study
DOCX
Binomial heap
PDF
C++ TUTORIAL 8
PDF
All I know about rsc.io/c2go
DOCX
bank management system
DOCX
Travel management
PDF
PDF
Introduction to Go for Java Programmers
Pratik Bakane C++
Pads lab manual final
Javascript & Ajax Basics
C++ file
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Assignement of programming & problem solving
Cpp tutorial
Un dsl pour ma base de données
Dex and Uniswap
Solidity
C++ Programming - 3rd Study
Binomial heap
C++ TUTORIAL 8
All I know about rsc.io/c2go
bank management system
Travel management
Introduction to Go for Java Programmers
Ad

Viewers also liked (10)

PPTX
Keek online android
DOCX
BCS THEORY NEW
PPTX
Účet v banke
DOCX
Resep masakan
PPTX
Balancing equations
PPTX
Masakan khas ala sunda
PPT
Stoichiometry
PDF
DOC
Masterscriptie S0315524
PPTX
Chapter 3 Chemical Bonding
Keek online android
BCS THEORY NEW
Účet v banke
Resep masakan
Balancing equations
Masakan khas ala sunda
Stoichiometry
Masterscriptie S0315524
Chapter 3 Chemical Bonding
Ad

Similar to Oop lab report (20)

DOCX
Tugas praktikukm pemrograman c++
PDF
Object Oriented Programming (OOP) using C++ - Lecture 3
PDF
C++ practical
DOCX
Opp compile
PDF
Pointers
DOCX
CS Project-Source code for shopping inventory for CBSE 12th
DOCX
Cs pritical file
PDF
Object Oriented Programming (OOP) using C++ - Lecture 2
DOCX
C++ file
PDF
C++ TUTORIAL 4
PDF
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
PDF
Computer_Practicals-file.doc.pdf
PDF
OOP_EXPLAINED_example_of_cod_and_explainations.pdf
DOC
Ds 2 cycle
DOCX
Pratik Bakane C++
PPTX
OOP-Lecture-05 (Constructor_Destructor).pptx
PDF
54602399 c-examples-51-to-108-programe-ee01083101
DOCX
code (1) thông tin nhập môn cntt hdsd.docx
Tugas praktikukm pemrograman c++
Object Oriented Programming (OOP) using C++ - Lecture 3
C++ practical
Opp compile
Pointers
CS Project-Source code for shopping inventory for CBSE 12th
Cs pritical file
Object Oriented Programming (OOP) using C++ - Lecture 2
C++ file
C++ TUTORIAL 4
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
Computer_Practicals-file.doc.pdf
OOP_EXPLAINED_example_of_cod_and_explainations.pdf
Ds 2 cycle
Pratik Bakane C++
OOP-Lecture-05 (Constructor_Destructor).pptx
54602399 c-examples-51-to-108-programe-ee01083101
code (1) thông tin nhập môn cntt hdsd.docx

Recently uploaded (20)

PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Basic Mud Logging Guide for educational purpose
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPH.pptx obstetrics and gynecology in nursing
102 student loan defaulters named and shamed – Is someone you know on the list?
O5-L3 Freight Transport Ops (International) V1.pdf
Institutional Correction lecture only . . .
Basic Mud Logging Guide for educational purpose
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Types and Its function , kingdom of life
FourierSeries-QuestionsWithAnswers(Part-A).pdf
VCE English Exam - Section C Student Revision Booklet
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Sports Quiz easy sports quiz sports quiz
Microbial diseases, their pathogenesis and prophylaxis

Oop lab report

  • 1. Comsats University of Science and Technology Islamabad LAB WORK 4 Name: Muhammad Tahir Roll No: Sp11-Bcs-107 Subject: Object Oriented Programming (Oop) Section: 3A Submitted To: Mam NusratShaheen Date:27/03/2012
  • 2. 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; }
  • 3. }; 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()
  • 4. { 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;
  • 5. 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) {
  • 6. } 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();
  • 7. 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; }
  • 8. 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; }
  • 9. 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{
  • 10. 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();}