ASSIGNMENT
Semester – 3rd (AI)
Subject – OOPs with C++
Date: 23-04-2025
INSTRUCTIONS
• You need to submit your hand-written assignment.
• You must write the following on the 1st page of your assignment.
➢ Name
➢ Roll number
➢ Registration number
➢ Semester
➢ Submitting faculty
• Deadline for the submission of your assignment is set on the date 30th of April 2024,
without fail.
• Must be written on A4 size Copy or Page with proper stick file.
• Your answer must be fair with question.
Unit-1: Introduction to C++
Marks: 20
Part A: Theory (10 Marks)
1. Explain the advantages of OOP over procedural programming. (2)
2. Differentiate between keywords and identifiers with examples. (2)
3. What are derived data types in C++? Explain any two with examples. (3)
4. Discuss type modifiers and typecasting with examples. (3)
Part B: Programming (10 Marks)
5. Write a C++ program to take input for two numbers, perform addition, subtraction,
multiplication, and division, and display the results. (5)
6. Write a program to demonstrate the use of strings by concatenating two strings and
finding the length of the resulting string. (5)
Unit-2: Control Structures and Functions
Marks: 25
Part A: Theory (10 Marks)
1. Compare if-else and switch-case statements with suitable examples. (3)
2. Explain break, continue, and goto statements with examples. (3)
3. Differentiate between while and do-while loops. (2)
4. What is function overloading? Provide an example. (2)
Part B: Programming (15 Marks)
5. Write a program to check if a number is prime or not using a for loop. (5)
6. Write a program to print the Fibonacci series up to n terms using a while loop. (5)
7. Create a function power() that calculates x^y (both int and float versions) using
function overloading. (5)
Unit-3: Classes and Data Abstraction
Marks: 25
Part A: Theory (10 Marks)
1. What is a class? How is it different from a structure in C++? (3)
2. Explain the concepts of constructors and destructors with examples. (3)
3. Differentiate between accessor and mutator functions. (2)
4. What is class scope? Explain with an example. (2)
Part B: Programming (15 Marks)
5. Create a class Student with attributes name, roll_no, and marks. Include member
functions to input and display student details. (5)
6. Write a program demonstrating the use of a constructor (default and parameterized)
and destructor. (5)
7. Implement a class Rectangle with private data members length and width. Use
accessor and mutator functions to modify and display values. (5)
Unit-4: Overloading, Templates, and Inheritance
Marks: 30
Part A: Theory (10 Marks)
1. Explain operator overloading with an example. (2)
2. What are function templates? How do they differ from class templates? (2)
3. Differentiate between single and multiple inheritance. (2)
4. What is an abstract class? Give an example. (2)
5. What is the ambiguity in defining hybrid inheritance how we can minimize or reduce
it? (2)
Part B: Programming (20 Marks)
5. Overload the + operator to add two complex numbers (real and imaginary parts). (5)
6. Create a function template swap() to swap two values of any data type. (5)
7. Implement single inheritance where a derived class Car inherits from a base class
Vehicle. Include at least two attributes and a member function. (5)
8. Demonstrate multiple inheritance with two base classes (Person and Employee) and a
derived class Manager. (5)