CS214 - IVSemBTech - (CS) Second Home Assignment

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

BTECH(CS) IV SEMESTER 2022

CS 214 Object Oriented Programming


SECOND HOME ASSIGNMENT

TOTAL MARKS: - 10

Q1. Why is the size of an empty class not zero in C++? Justify your answer.

Q2. What is reference variable? Write a function using reference variable as argument to swap
the values of pair of integer.

Q3. What is a friend function? What are merit and demerits of using friend function?

Q4. Write a program in C++ to add and multiply two complex numbers using friend function.

Q5. What do you mean by polymorphism? How is late binding different from early binding?

Q6. What do you mean by a virtual function? Explain its use with a suitable example program?

Q7. What is virtual base class? Explain with an example.

Q8. Write a C++ program to pick the largest number from any 4 X 4 matrix.

Q9. Differentiate between

(a) getline() and get() functions.

(b) ios::ate and ios::app

(c ) ifstream class and ofstream class

Q10. How many arguments are required in the definition of an overloaded binary operator?

Q11. The annual examination is conducted for 50 students for three subjects. Write a program to
read the data and determine the following:

 Total marks obtained by each student.

 The student who obtained the highest total marks.

Q12. Create two objects of s1 and s2 of class STRING.


STRING s1=”Banasthali”;
STRING s2=”Vidyapith”;
Implement the following and write the output of each operation

(i) Copy the content of s1 to s2.


(ii) Find the substring “Vidya” in s2.
(iii) Compare s1 and s2.
1

You might also like