Punjab University
BS Computer Science (BSCS)
Object Oriented Programming (Code: CC211)
Maximum Marks: 75 + Viva (25) = 100 Marks
Section A – Long Questions
Question 1 (25 Marks)
Write a C++ program to create a class Student having the following data members:
Student ID, Student Name, Department, Marks in three subjects
Requirements:
Create member functions to input and display student information.
Calculate the average marks of the student.
Display the grade according to the following criteria:
Average Marks Grade
80 – 100 A
70 – 79 B
60 – 69 C
50 – 59 D
Below 50 Fail
Create two objects in main() and display their results.
Question 2 (25 Marks)
Create a class Complex that represents a complex number with two data members:
Real and imaginary
Requirements:
1. Create a constructor to initialize the values of the complex numbers.
2. Overload the + operator to add two complex numbers.
3. Create a member function to display the result in the form a + bi.
4. In the main() function, create two objects of the Complex class, add them using the
overloaded operator, and display the result.
Question 3 (25 Marks)
Write a C++ program that create a base class Shape with a virtual function calculateArea().
Create two derived classes:
1)Rectangle (length, width)
2)Circle (radius)
Override the calculateArea() function in both derived classes.
Call the appropriate function in main and display the area.
Section B – Viva Voce (25 Marks)