Oops
Oops
SEMESTER III
1. Subject Code: PCS 307 Course Title: OOP WITH C++ LAB
2. Contact Hours: L: 0 T: 1 P: 2
5. Credits: 2
6. Semester: III
7. Category of Course: DC
9. Course After completion of the course the students will be able to:
Outcome**: CO1: Evaluate the basic difference between object-oriented programming
and procedural language and their data types.
CO2: Implement the programs using C++ features such as object
creation, compile time polymorphism, inheritance, abstraction,
encapsulation etc.
CO3: Design and solve programs that incorporates the use of object-
oriented techniques such as abstract classes, pure virtual functions,
and constructors.
Input
First line contains an integer as input. Next line contains space separated integers
denoting the elements of the array
4.
Output
In the output you have to print an integer that denotes the maximum special sum
Input/Output Format
Typical Input Expected Output
5 8
13125
10 9
2 1 3 9 2 4 -10 -9 1 3
5. Implement a C++ program to demonstrate the concept of data abstraction using the
concept of Class and Objects
20. Implement a real case scenario by a proper C++ code to provide the solution to
Diamond Problem in C++
Create a base class called shape. Use this class to store two double type values that
could be used to compute the area of figures. Derive two specific classes called
triangle and rectangle from base shape. Add to the base class, a member function
get_data() to initialize base class data members and another member function
display_area() to compute and display the area of figures. Make display_area() as a
virtual function and redefine this function in the derived class to suit their
21. requirements. Using these three classes, design a program that will accept
dimensions of a triangle or a rectangle interactively and display the area. Remember
the two values given as input will be treated as lengths of
two sides in the case of rectangles and as base and height in the case of triangle and
used as follows:
Area of rectangle = x * y
Area of triangle = ½ *x*y
Create a base class called CAL_AREA(Abstract). Use this class to store float type
values that could be used to compute the volume of figures. Derive two specific
classes called cone, hemisphere and cylinder from the base CAL_AREA. Add to
the base class, a member function getdata ( ) to initialize base class data members
and another member function display volume( ) to compute and display the volume
21. of figures. Make display volume ( ) as a pure virtual function and redefine this
function in the derived classes to suit their requirements. Using these three classes,
design a program that will accept dimensions of a cone, cylinder and hemisphere
interactively
and display the volumes. Remember values given as input will be and used as
follows:
Volume of cone = (1/3)πr2h
Volume of hemisphere = (2/3)πr3
Volume of cylinder = πr2h
The task is to debug the existing code to successfully execute all provided test files.
You are required to extend the existing code so that it handles the
std::invalid_argument exception properly. More specifically, you have to extend the
implementation of the process_input function. It takes integer n as an argument and
has to work as follows:
1.It calls function largest_proper_divisor(n).
2.If this call returns a value without raising an exception, it should print in a single
line result=d where d is the returned value.
3.Otherwise, if the call raises an invalid_argument exception, it has to print in a
single line the string representation of the raised exception, i.e., its message.
4.Finally, no matter if the exception is raised or not, it should print in a single line
returning control flow to the caller after any other previously printed output.
Input Format
The input is read by the provided locked code template. In the only line of the input,
there is a single integer n, which is going to be the argument passed to function
process input.
22.
Output Format
12. Mode of Evaluation Test / Quiz / Assignment / Mid Term Exam / End Term Exam