Docsity

OOPS THIRTY PROGRAMS WITH THEIR OUTPUTS, Schemes and Mind Maps of Object Oriented Programming

Toggle sidebar
bg1
Object Oriented Programming With C++BCA Department
Govt. Degree College Chamba(H.P)
1. Program to show use of Arithmetic operations using
Class and Objects.
#include<iostream.h>
#include<conio.h>
class operation
{
private:
int a,b;
public:
void read()
{
cout<<"Enter Two Numbers :";
cin>>a>>b;
}
void show()
{
cout<<"You Enter\na = "<<a<<"\nb = "<<b;
}
void addition()
{
int r=a+b;
cout<<"\nAddition of given number is : "<<r;
}
void subtraction()
{
int r=a-b;
cout<<"\nSubtraction of given numbers is : "<<r;
}
void multiplication()
{
int r=a*b;
cout<<"\nMultiplication of given numbers is : "<<r;
}
void division()
{
if(b!=0)
{
int r=a/ b;
cout<<"\nDivision of given numbers is : "<<r;
}
else
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download OOPS THIRTY PROGRAMS WITH THEIR OUTPUTS and more Schemes and Mind Maps Object Oriented Programming in PDF only on Docsity!

1. Program to show use of Arithmetic operations using

Class and Objects.

#include #include class operation { private: int a,b; public: voidread() { cout<<"Enter TwoNumbers :"; cin>>a>>b; } voidshow() { cout<<"You Enter\na = "< cout<<"\nCannotDivideBy Zero "; } voidmodulus( ) { int r=a%b; cout<<"\nModulus of given number is : "<

3. Programto Pass Object as Argument Through Function.

#include #include class sum { private: int a,b,r1,r2; public: voidinput(); void add(sum,sum); voidoutput(); }; void sum::input() { cout<<"Enter value of a Andb :"; cin>>a>>b; } void sum::add(sum ss1,sum ss2) { r1=ss1.a+ss2.a; r2=ss1.b+ss2.b; } void sum::output() { cout<<"value on Addition :"; cout<

5. Program to Enter and Display Data of StudentUsing

Structure.

#include #include struct student { int roll_no; char name[20]; float per; }; void main() { clrscr(); student s1; cout<<"Enter Student Details :>\ n"; cout<<"Enter RollNo :"; cin>>s1.roll_no; cout<<"EnterName :"; cin.ignore(); cin.get(s1.name,20); cout<<"EnterPercentage :"; cin>>s1.per; cout<<"\nDetailsof Student are :>"; cout<<"\nRollNo : "<

6. Program to Enter Employee Data Using Nested of

Structure.

#include #include struct date { int day; int month; int year; }; struct employee { int emp_id; char name[20]; char dept_name[20]; double salary; date doj; }; void main() { clrscr(); employee e1; cout<<"Enter Employee Details :>\ n"; cout<<"Enter EmployeeID :"; cin>>e1.emp_id; cout<<"Enter EmployeeName :"; cin.ignore(); cin.get(e1.name,20); cout<<"Enter DepartmentName :"; cin.ignore(); cin.get(e1.dept_name,20); cout<<"EnterSalary :"; cin>>e1.salary; cout<<"Enter Date OfJoining :"; cin>>e1.doj.day>>e1.doj.month>>e1.doj.year; cout<<"DEtailsof Employeeare :\ n"; cout<<"\nID : "< cout<<"\nDate of Joining : "<

8. Program to ShowWorking ofDefault Constructor.

#include #include class rectangle { private: int length,breadth; public: rectangle() { length=10; breadth=20; } int area() { return(length*breadth); } }; void main() { clrscr(); rectangle r1; int ar=r1.area(); cout<<"Area ofrectangle is: "<

9. Program to ShowWorking ofParemetrizedConstructor.

#include #include class rectangle { private: int length,breadth; public: rectangle(int l,intb) { length=l; breadth=b; } int area() { return(length*breadth); } }; void main() { clrscr(); rectangle r1(10,20); rectangle r2(5,6); cout<<"Area of Rectangle r1is : "<

11. Program to Show Working of Destructor.

#include #include class counter { private: int id; public: counter(int i) { id=i; cout<<"\nObjectwithID :"<

void result::call() { int marks=0; for(int i=0;i<4;i++) { marks=marks+m[i]; } total_marks=marks; per=total_marks/ 4; } void result::output() { show(); cout<<"\nTotalMarks = "<

13. Program to show MultipleInharitance.

#include #include class publication { private: char publisher[20]; protected: double price; public: voidread() { cout<<"\nEnterPublisher andPrice :"; cin>>publisher>>price; } voidshow() { cout<<"\nPublisher: "<>pub_sales; } voidshow() { cout<<"\nTotalsales of Publication :"<