0% found this document useful (0 votes)
37 views9 pages

DCO-312 Practical File10

The document is a practical record for an Object Oriented Programming lab course. It contains details of the student such as their name, roll number, and semester. The record then lists 13 programs the student completed for the course to demonstrate different OOP concepts in C++ like inheritance, polymorphism, encapsulation etc. It provides the name and date of completion for each program and space for the teacher's signature after evaluation.

Uploaded by

skri d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views9 pages

DCO-312 Practical File10

The document is a practical record for an Object Oriented Programming lab course. It contains details of the student such as their name, roll number, and semester. The record then lists 13 programs the student completed for the course to demonstrate different OOP concepts in C++ like inheritance, polymorphism, encapsulation etc. It provides the name and date of completion for each program and space for the teacher's signature after evaluation.

Uploaded by

skri d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

OBJECT ORIENTED PROGRAMMING LAB

(DCO-312)

Submitted to:
Dr. Sunil & Ms. Farah Jamal Ansari
Assistant Professor

Submitted by
Student Name SHAYAN AHSAN
Roll No.:20DCS048
Semester: III SEMESTER

Computer Engineering Section


University Polytechnic
Faculty of Engineering & Technology
Jamia Millia Islamia, New Delhi-110025
PRACTICAL RECORD

PAPER CODE : DCO-312


Name of the Student : SHAYAN AHSAN
University Roll No. : 20DCS048
Section : DIPLOMA IN COMPUTER ENGINEERING

PRACTICAL DETAILS
Practical Practical Name Date of Date of Marks/ Teacher’s
No. Performance Checking Grades Signature
1. 9th Sept,2021
WRITE PROGRAMS IN
C++ TO IMPLEMENT
VARIOUS CONTROL
STATEMENTS
2. Write the C++ programs to 23rdSept,202
understand Structure 1
3. Write the C++ program to 23rd
understand functions Sept,2021
4. Write a program in C++ to 23rd Oct,2021
Understand Pointer
Arithmetic
5. Write Programs in C++ to 29th
Understand different
Sept,2021
function call mechanism.
      a. Call by Value b. Call
by reference
6. Write a program in C++ to 29th
understand classes and Sept,2021
objects
7. Write a program in C++ to 20th Oct,2021
understand inline function.
8. Write a program in C++ to 20th Oct,2021
understand Constructors &
Destructors.
9. Write a program in C++ 20th Oct,2021
using classes to
demonstrate the Use of
“this” Pointer.
10. Write Programs in C++ to 14thNov,202
Implement all types of 1
Inheritance.
11.

12.

13. Write a program in C++ to 14thNov,202


understand Friend Function 1
&Friend Class
14.

15.
PROGRAM 13: To Understand TYPES of INHERITANCE
A.Single Inheritance
INPUT
//Single inheritance
#include<iostream>
using namespace std;
class A{ //base class
int a;
int b;
 public:
int mul()
{
    cout<<"\n Enter value of a & b: ";
cin>>a>>b;
int c= a*b;
return c;}
};
class B: public A        //derived class
{public:
void display()
{int result = mul();
cout <<"\n Multiplication of a and b is : "<<result;
}
};
int main()
{
B b;
b.display();
return 0;
}
OUTPUT
b.Multilevel Inheritance
INPUT

#include<iostream>
#include<conio.h>
using namespace std;
class base     //single base class
{ public:
int x;
void getdata()
{cout << "Enter value of x= ";
 cin >> x;
}
};

class FirstDerived : public base // derived class from base class


{
     public:
int y;
void readdata()
{cout << "\nEnter value of y= ";
 cin >> y;
}
};
class SecondDerived : public FirstDerived // derived from class derivel
{ private:
int z;
public:
void indata()
{ cout << "\nEnter value of z= ";
cin >> z;
}
void product()
{ cout << "\nProduct= "<< x * y * z;
}
};
int main()
{
SecondDerived a;         //object of derived class
a.getdata();
a.readdata();
a.indata();
a.product();
getch();
return 0;
}
OUTPUT
Enter value of x= 4
Enter value of y= 2
Enter value of z= 25
Product= 200
C.hierarchical Inheritance
INPUT
//Hierarchical Inheritance
#include<iostream>
#include<conio.h>
using namespace std;
class A   {  //single base class
public:
int x, y;
void getdata()
{ cout << "\nEnter value of x and y: \n";
cin>>x>>y;
}
};
class B: public A   //B is derived from class base
{ public:
void product()
{cout << "\nProduct=" << x*y;
}
};
class C: public A //C is also derived from class base
{ public:
 void sum()
{ cout << "\nSum="<< x+ y;
}
};
int main()
{
B obj1;   //object of derived class B
C obj2;   //object of derived class C
obj1.getdata();
obj1.product();
obj2.getdata();
obj2.sum();
getch ();
return 0;
}

OUTPUT
Enter value of x and y:
4
6
Product=24
Enter value of x and y:
4
6
Sum=10
D.MULTIPLE INHERITANCE
INPUT
//Multiple Inheritance
#include<iostream>
#include<conio.h>
using namespace std;
class A
{ public:
int x;
void getx(){ cout << "enter value of x: ";
cin >> x;
}
};
class B
{ public:
int y;
void gety()
{cout << "enter value of y: ";
cin >> y;
}
};
class C: public A, public B //C is derived from class A and class B
{ public:
void sum()
{cout << "Sum = " << x + y;
}
};
int main(){
C obj;    //object of derived class C
obj.getx();
obj.gety();
obj.sum();

getch();
return 0;
}

OUTPUT
enter value of x: 4
enter value of y: 5
Sum = 9
E.HYBRID/VIRTUAL INHERITANCE
INPUT
#include<iostream>
#include<conio.h>
using namespace std;

class A{     //base class

public:
int length;
 void Ab(){
    cout<<"Enter the value of the length ="<<endl;
    cin>>length;
}
};
class B{  //base class

public:
int breadth;
void Ba(){    
    cout<<"Enter the value of breadth = "<<endl;
    cin>>breadth;
}
};
class C:public A,public B{

public:
  int Sum=length+breadth;
void S(){
 
    cout<<"Sum of length and breadth is "<<Sum;
}
};
class D:public C{
public:
int height;
void lateralSurfaceAreaofCuboid(){
int lateraArea=2*(Sum)*height;
}
};

int main(){
A EnterLENGTH;
EnterLENGTH.Ab();
B EnterBREADTH;
EnterBREADTH.Ba();
C obj3;
obj3.S();
D lateralArea;
lateralArea.lateralSurfaceAreaofCuboid();
getch();
    return 0;
}
OUTPUT

You might also like