SlideShare a Scribd company logo
1 of 10
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

What's hot

Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual finalAhalyaR
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax BasicsRichard Paul
 
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...Gene Leybzon
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solvingSyed Umair
 
Un dsl pour ma base de données
Un dsl pour ma base de donnéesUn dsl pour ma base de données
Un dsl pour ma base de donnéesRomain Lecomte
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd StudyChris Ohk
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
bank management system
bank management systembank management system
bank management systemAisha Aisha
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 

What's hot (20)

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
C++ file
C++ fileC++ file
C++ file
 
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Un dsl pour ma base de données
Un dsl pour ma base de donnéesUn dsl pour ma base de données
Un dsl pour ma base de données
 
Dex and Uniswap
Dex and UniswapDex and Uniswap
Dex and Uniswap
 
Solidity
SoliditySolidity
Solidity
 
MFC Cosinus
MFC CosinusMFC Cosinus
MFC Cosinus
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
Binomial heap
Binomial heapBinomial heap
Binomial heap
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
bank management system
bank management systembank management system
bank management system
 
Travel management
Travel managementTravel management
Travel management
 
Sol10
Sol10Sol10
Sol10
 
Textile
TextileTextile
Textile
 
Introduction to Go for Java Programmers
Introduction to Go for Java ProgrammersIntroduction to Go for Java Programmers
Introduction to Go for Java Programmers
 

Viewers also liked

Viewers also liked (10)

Keek online android
Keek online androidKeek online android
Keek online android
 
BCS THEORY NEW
BCS THEORY NEWBCS THEORY NEW
BCS THEORY NEW
 
Účet v banke
Účet v bankeÚčet v banke
Účet v banke
 
Resep masakan
Resep masakanResep masakan
Resep masakan
 
Balancing equations
Balancing equationsBalancing equations
Balancing equations
 
Masakan khas ala sunda
Masakan khas ala sunda Masakan khas ala sunda
Masakan khas ala sunda
 
Stoichiometry
StoichiometryStoichiometry
Stoichiometry
 
EOD
EODEOD
EOD
 
Masterscriptie S0315524
Masterscriptie S0315524Masterscriptie S0315524
Masterscriptie S0315524
 
Chapter 3 Chemical Bonding
Chapter 3 Chemical BondingChapter 3 Chemical Bonding
Chapter 3 Chemical Bonding
 

Similar to Oop lab report

Similar to Oop lab report (20)

Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Opp compile
Opp compileOpp compile
Opp compile
 
Pointers
PointersPointers
Pointers
 
P1
P1P1
P1
 
CS Project-Source code for shopping inventory for CBSE 12th
CS Project-Source code for shopping inventory for CBSE 12thCS Project-Source code for shopping inventory for CBSE 12th
CS Project-Source code for shopping inventory for CBSE 12th
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
C++ file
C++ fileC++ file
C++ file
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
File Handling Program
File Handling ProgramFile Handling Program
File Handling Program
 
Constructor and Destructors in C++
Constructor and Destructors in C++Constructor and Destructors in C++
Constructor and Destructors in C++
 
oodp elab.pdf
oodp elab.pdfoodp elab.pdf
oodp elab.pdf
 
C++ L07-Struct
C++ L07-StructC++ L07-Struct
C++ L07-Struct
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 

Recently uploaded

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 

Recently uploaded (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 

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();}