SlideShare a Scribd company logo
1 of 21
Q. Write a function two digit inverse() that reverse the digits of a two digit integer.
Code:-
#include<iostream.h>
#include<conio.h>
class rev
{
private:
int a,b,c,d;
public:
void getdata()
{
cout<<"enter the no u wanna rev:";
cin>>a;
}
void getrev()
{
c=a%10;
b=a/10;
d=c*10+b;
}
void display()
{
cout<<"nthe no after reversing is:"<<d;
}
};
void main()
{
clrscr();
rev a1;
a1.getdata();
a1.getrev();
a1.display();
getch();
}
OUTPUT
Q. WAP for class account which contains two private data elements, an integer account no
and a floating point account balance, and three member function.
CODE:-
#include<iostream.h>
#include<conio.h>
class accclass
{
private:
int accno;
int bal;
public:
void getdata()
{
cout<<"nenter the account number for acc1:";
cin>>accno;
cout<<"nenter the balance:";
cin>>bal;
}
void setdata(int accin)
{
accno=accin;
bal=0;
}
void setdata(int accin,float balin)
{
accno=accin;
bal=balin;
}
void display()
{
cout<<"naccount no is: "<<accno;
cout<<"nbalance is: "<<bal;
}
void moneytransfer(accclass &acc,float amount);
};
void accclass::moneytransfer(accclass &acc,float amount)
{
bal=bal-amount;
acc.bal=acc.bal+amount;
}
void main()
{
clrscr();
int trans_money;
accclass acc1,acc2,acc3;
acc1.getdata();
acc2.setdata(34);
acc3.setdata(29,456);
cout<<"nACCOUNT INFO";
acc1.display();
acc2.display();
acc3.display();
cout<<"nhow much money u want to b transferred from acc3 to acc1:";
cin>>trans_money;
acc3.moneytransfer(acc1,trans_money);
cout<<"nupdate info about accounts";
acc1.display();
acc2.display();
acc3.display();
getch();
}
OUTPUT
Q. Program for Inline functions concept.
CODE:-
#include<conio.h>
#include<iostream.h>
class date
{
private:
int day;
int month;
int year;
public:
void set(int dayin,int monthin,int yearin);
void show();
};
inline void date::set(int dayin,int monthin,int yearin)
{
day=dayin;
month=monthin;
year=yearin;
}
inline void date::show()
{
cout<<day<<"-"<<month<<"-"<<year;
}
void main()
{
date d1,d2,d3;
d1.set(26,3,1958);
d2.set(14,4,1995);
d3.set(1,4,1972);
cout<<"nnBirth DAate of 1st Author : ";
d1.show();
cout<<"nnBirth DAate of 2nd Author : ";
d2.show();
cout<<"nnBirth DAate of 3rd Author : ";
d3.show();
getch();
}
OUTPUT
Q. WAP for area of circle square and rectangle.
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int choice;
float a,r,c,b,d,areac,arear,areas;
cout<<"enter ur choice:";
cout<<"nenter 1 for area of sqre:nenter 2 for circle areanenter 3 for area of rectanglen";
cin>>choice;
switch(choice)
{
case 1:
{
cout<<"nenter the side:";
cin>>a;
areas=a*a;
cout<<"narea="<<areas;
}
case 2:
{
cout<<"enter the radius";
cin>>r;
areac=3.14*r*r;
cout<<"nthe area="<<areac;
}
case 3:
{
cout<<"enter the sides of rectangle:";
cin>>b>>d;
arear=b*d;
cout<<"area="<<arear;
}
}
getch();
}
OUTPUT
Q. WAP to convert Fahrenheit into Celsius.
CODE:-
#include<iostream.h>
#include<conio.h>
class temp
{
private:
float faren;
float cel;
public:
void getdata()
{
cout<<"nnenter the degree in farenheit:";
cin>>faren;
}
void cal()
{
cel=(faren-32)*5/9;
cout<<"ndegree in celsius= "<<cel;
}
};
void main()
{
temp f1;
f1.getdata();
f1.cal();
getch(); }
OUTPUT
Q. WAP that will convert fraction into a mixed number.your function is required in
decimal.
CODE:-
#include<iostream.h>
#include<conio.h>
class converter
{
private:
int mixed;
float deci,n1;
public:
void getdata()
{
cout<<"enter the no:";
cin>>n1;
}
void cal()
{
mixed=n1/1;
deci=n1-mixed;
cout<<"nnow the number is mixed="<<mixed;
cout<<"ndeci="<<deci;
}
};
void main()
{
clrscr();
converter c1;
c1.getdata();
c1.cal();
getch();
}
OUTPUT
Q. WAP to show the use of friend class concept.
CODE:-
#include<iostream.h>
#include<conio.h>
class girl;
class boy
{
int income1,income2;
public:
void setdata(int in1,int in2)
{
income1=in1;
income2=in2;
}
friend class girl;
};
class girl
{
int income;
public:
int girlfunc(boy b1)
{
return b1.income1+b1.income2;
}
void show()
{
boy d;
d.setdata(100,200);
cout<<"n boy's income in show():"<<d.income1;
}
};
void main()
{ boy b1;
girl g1;
b1.setdata(500,1000);
cout<<"n boy b1 total income:"<<g1.girlfunc(b1);
g1.show();
getch();
}
OUTPUT
Q. WAP to show the concept of Friend Function
CODE:-
#include<iostream.h>
#include<conio.h>
class two;//forward declaration
class one
{
int i;
public:
void get()
{
cout<<"n enter the value:";
cin>>i;
}
friend void disp(one num1,two num2);
};
class two
{
int j;
public:
void get()
{
cout<<"n enter the value:";
cin>>j;
}
friend void disp(one num1,two num2);
};
void disp( one num1,two num2)
{
int c;
c=num1.i+num2.j;
cout<<"n the sum is:"<<c;
}
void main()
{ clrscr();
one num1;
two num2;
num1.get();
num2.get();
disp(num1,num2);
getch();
}
OUTPUT
Q. WAP to use the concept of constructors and destructors.
CODE:-
#include<iostream.h>
#include<conio.h>
class hotel
{
int roomno, roomrent;
public:
hotel()
{
roomno=1;
roomrent=4000;
}
void display();
};
void hotel::display()
{
cout<<"n room no. is:"<<roomno;
cout<<"n room rent is :"<<roomrent;
}
void main()
{
clrscr();
hotel obj1,obj2;
obj1.display();
obj2.display();
getch();
}
OUTPUT
Q. Use of default constructor without argument.
CODE:-
#include<iostream.h>
#include<conio.h>
class hotel
{
private:
int roomno;
int roomrent;
public:
hotel()
{
roomno=1;
roomrent=4000;
}
void display();
};
void hotel::display()
{
cout<<"nroom number= "<<roomno;
cout<<"nromm rent="<<roomrent;
}
void main()
{
clrscr();
hotel ob1,ob2;
ob1.display();
ob2.display();
getch();
}
OUTPUT

More Related Content

What's hot (20)

C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Shan
ShanShan
Shan
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
C test
C testC test
C test
 
week-1x
week-1xweek-1x
week-1x
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
 
week-10x
week-10xweek-10x
week-10x
 
week-6x
week-6xweek-6x
week-6x
 
week-11x
week-11xweek-11x
week-11x
 
Linked list2
Linked list2Linked list2
Linked list2
 
Cse presentation ratul
Cse presentation ratulCse presentation ratul
Cse presentation ratul
 
MATLAB CODE OF Shifting sequence
MATLAB  CODE  OF Shifting sequenceMATLAB  CODE  OF Shifting sequence
MATLAB CODE OF Shifting sequence
 
matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequences
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
C Programming
C ProgrammingC Programming
C Programming
 
Program for pyramid
Program for pyramidProgram for pyramid
Program for pyramid
 
To designing counters using verilog code
To designing counters using verilog codeTo designing counters using verilog code
To designing counters using verilog code
 
week-18x
week-18xweek-18x
week-18x
 

Similar to C++ (20)

C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
CppTutorial.ppt
CppTutorial.pptCppTutorial.ppt
CppTutorial.ppt
 
Oop1
Oop1Oop1
Oop1
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
Assignment#1
Assignment#1Assignment#1
Assignment#1
 
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
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
C++ practical
C++ practicalC++ practical
C++ practical
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 

More from Raj vardhan

Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3Raj vardhan
 
Internet Basics Unit-7
Internet Basics  Unit-7Internet Basics  Unit-7
Internet Basics Unit-7Raj vardhan
 
Local Area Network – Wired LAN
Local Area Network – Wired LANLocal Area Network – Wired LAN
Local Area Network – Wired LANRaj vardhan
 
Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5Raj vardhan
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CRaj vardhan
 
Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture Raj vardhan
 
UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices Raj vardhan
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteRaj vardhan
 
Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2Raj vardhan
 
Swachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project ReportSwachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project ReportRaj vardhan
 
Network Topology
Network TopologyNetwork Topology
Network TopologyRaj vardhan
 
Microsoft Office Word Introduction Complete
Microsoft Office Word  Introduction CompleteMicrosoft Office Word  Introduction Complete
Microsoft Office Word Introduction CompleteRaj vardhan
 
Digital money Revolution Introduction
Digital money Revolution IntroductionDigital money Revolution Introduction
Digital money Revolution IntroductionRaj vardhan
 
Definition of Business
Definition of BusinessDefinition of Business
Definition of BusinessRaj vardhan
 
Business Terms & Concepts
Business Terms & ConceptsBusiness Terms & Concepts
Business Terms & ConceptsRaj vardhan
 
Number System Conversion | BCA
Number System Conversion | BCANumber System Conversion | BCA
Number System Conversion | BCARaj vardhan
 
Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FITRaj vardhan
 
FIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCAFIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCARaj vardhan
 
Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205 Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205 Raj vardhan
 

More from Raj vardhan (20)

Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3Software Testing Life Cycle Unit-3
Software Testing Life Cycle Unit-3
 
Internet Basics Unit-7
Internet Basics  Unit-7Internet Basics  Unit-7
Internet Basics Unit-7
 
Local Area Network – Wired LAN
Local Area Network – Wired LANLocal Area Network – Wired LAN
Local Area Network – Wired LAN
 
Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5Network Connecting Devices UNIT 5
Network Connecting Devices UNIT 5
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
 
Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture Wireless LANs(IEEE802.11) Architecture
Wireless LANs(IEEE802.11) Architecture
 
UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices UNIT -03 Transmission Media and Connecting Devices
UNIT -03 Transmission Media and Connecting Devices
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
 
Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2Introduction To Software Concepts Unit 1 & 2
Introduction To Software Concepts Unit 1 & 2
 
Swachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project ReportSwachh Bharat Abhiyan - Project Report
Swachh Bharat Abhiyan - Project Report
 
Network Topology
Network TopologyNetwork Topology
Network Topology
 
Microsoft Office Word Introduction Complete
Microsoft Office Word  Introduction CompleteMicrosoft Office Word  Introduction Complete
Microsoft Office Word Introduction Complete
 
Digital money Revolution Introduction
Digital money Revolution IntroductionDigital money Revolution Introduction
Digital money Revolution Introduction
 
C Programming
C ProgrammingC Programming
C Programming
 
Definition of Business
Definition of BusinessDefinition of Business
Definition of Business
 
Business Terms & Concepts
Business Terms & ConceptsBusiness Terms & Concepts
Business Terms & Concepts
 
Number System Conversion | BCA
Number System Conversion | BCANumber System Conversion | BCA
Number System Conversion | BCA
 
Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FIT
 
FIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCAFIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCA
 
Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205 Syllabus Front End Design Tool VB.NET | BCA-205
Syllabus Front End Design Tool VB.NET | BCA-205
 

Recently uploaded

CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

C++

  • 1. Q. Write a function two digit inverse() that reverse the digits of a two digit integer. Code:- #include<iostream.h> #include<conio.h> class rev { private: int a,b,c,d; public: void getdata() { cout<<"enter the no u wanna rev:"; cin>>a; } void getrev() { c=a%10; b=a/10; d=c*10+b; } void display() { cout<<"nthe no after reversing is:"<<d; } }; void main() { clrscr(); rev a1; a1.getdata(); a1.getrev(); a1.display(); getch(); }
  • 3. Q. WAP for class account which contains two private data elements, an integer account no and a floating point account balance, and three member function. CODE:- #include<iostream.h> #include<conio.h> class accclass { private: int accno; int bal; public: void getdata() { cout<<"nenter the account number for acc1:"; cin>>accno; cout<<"nenter the balance:"; cin>>bal; } void setdata(int accin) { accno=accin; bal=0; } void setdata(int accin,float balin) { accno=accin; bal=balin; } void display() { cout<<"naccount no is: "<<accno; cout<<"nbalance is: "<<bal; } void moneytransfer(accclass &acc,float amount); }; void accclass::moneytransfer(accclass &acc,float amount) { bal=bal-amount; acc.bal=acc.bal+amount; } void main() { clrscr(); int trans_money;
  • 4. accclass acc1,acc2,acc3; acc1.getdata(); acc2.setdata(34); acc3.setdata(29,456); cout<<"nACCOUNT INFO"; acc1.display(); acc2.display(); acc3.display(); cout<<"nhow much money u want to b transferred from acc3 to acc1:"; cin>>trans_money; acc3.moneytransfer(acc1,trans_money); cout<<"nupdate info about accounts"; acc1.display(); acc2.display(); acc3.display(); getch(); }
  • 6. Q. Program for Inline functions concept. CODE:- #include<conio.h> #include<iostream.h> class date { private: int day; int month; int year; public: void set(int dayin,int monthin,int yearin); void show(); }; inline void date::set(int dayin,int monthin,int yearin) { day=dayin; month=monthin; year=yearin; } inline void date::show() { cout<<day<<"-"<<month<<"-"<<year; } void main() { date d1,d2,d3; d1.set(26,3,1958); d2.set(14,4,1995); d3.set(1,4,1972); cout<<"nnBirth DAate of 1st Author : "; d1.show(); cout<<"nnBirth DAate of 2nd Author : "; d2.show(); cout<<"nnBirth DAate of 3rd Author : "; d3.show(); getch(); }
  • 8. Q. WAP for area of circle square and rectangle. CODE:- #include<iostream.h> #include<conio.h> void main() { clrscr(); int choice; float a,r,c,b,d,areac,arear,areas; cout<<"enter ur choice:"; cout<<"nenter 1 for area of sqre:nenter 2 for circle areanenter 3 for area of rectanglen"; cin>>choice; switch(choice) { case 1: { cout<<"nenter the side:"; cin>>a; areas=a*a; cout<<"narea="<<areas; } case 2: { cout<<"enter the radius"; cin>>r; areac=3.14*r*r; cout<<"nthe area="<<areac; } case 3: { cout<<"enter the sides of rectangle:"; cin>>b>>d; arear=b*d; cout<<"area="<<arear; } } getch(); }
  • 10. Q. WAP to convert Fahrenheit into Celsius. CODE:- #include<iostream.h> #include<conio.h> class temp { private: float faren; float cel; public: void getdata() { cout<<"nnenter the degree in farenheit:"; cin>>faren; } void cal() { cel=(faren-32)*5/9; cout<<"ndegree in celsius= "<<cel; } }; void main() { temp f1; f1.getdata(); f1.cal(); getch(); }
  • 12. Q. WAP that will convert fraction into a mixed number.your function is required in decimal. CODE:- #include<iostream.h> #include<conio.h> class converter { private: int mixed; float deci,n1; public: void getdata() { cout<<"enter the no:"; cin>>n1; } void cal() { mixed=n1/1; deci=n1-mixed; cout<<"nnow the number is mixed="<<mixed; cout<<"ndeci="<<deci; } }; void main() { clrscr(); converter c1; c1.getdata(); c1.cal(); getch(); }
  • 14. Q. WAP to show the use of friend class concept. CODE:- #include<iostream.h> #include<conio.h> class girl; class boy { int income1,income2; public: void setdata(int in1,int in2) { income1=in1; income2=in2; } friend class girl; }; class girl { int income; public: int girlfunc(boy b1) { return b1.income1+b1.income2; } void show() { boy d; d.setdata(100,200); cout<<"n boy's income in show():"<<d.income1; } }; void main() { boy b1; girl g1; b1.setdata(500,1000); cout<<"n boy b1 total income:"<<g1.girlfunc(b1); g1.show(); getch(); }
  • 16. Q. WAP to show the concept of Friend Function CODE:- #include<iostream.h> #include<conio.h> class two;//forward declaration class one { int i; public: void get() { cout<<"n enter the value:"; cin>>i; } friend void disp(one num1,two num2); }; class two { int j; public: void get() { cout<<"n enter the value:"; cin>>j; } friend void disp(one num1,two num2); }; void disp( one num1,two num2) { int c; c=num1.i+num2.j; cout<<"n the sum is:"<<c; } void main() { clrscr(); one num1; two num2; num1.get(); num2.get(); disp(num1,num2); getch(); }
  • 18. Q. WAP to use the concept of constructors and destructors. CODE:- #include<iostream.h> #include<conio.h> class hotel { int roomno, roomrent; public: hotel() { roomno=1; roomrent=4000; } void display(); }; void hotel::display() { cout<<"n room no. is:"<<roomno; cout<<"n room rent is :"<<roomrent; } void main() { clrscr(); hotel obj1,obj2; obj1.display(); obj2.display(); getch(); }
  • 20. Q. Use of default constructor without argument. CODE:- #include<iostream.h> #include<conio.h> class hotel { private: int roomno; int roomrent; public: hotel() { roomno=1; roomrent=4000; } void display(); }; void hotel::display() { cout<<"nroom number= "<<roomno; cout<<"nromm rent="<<roomrent; } void main() { clrscr(); hotel ob1,ob2; ob1.display(); ob2.display(); getch(); }