C++Practical File
C++Practical File
Studies
(Affiliated to Guru Gobind Singh Indraprastha University, Delhi)
Ranked “A+” Institution by SFRC, Govt. of NCT of India
Recognized under section 2(f) of the UGC Act, 1956
NAAC Accredited “B++” Grade Institution
Practical File of
C++ Lab
OUTPUT
Q 5. Write a program using inline function to find minimum of two values.
OUTPUT
OUTPUT
Q 8. Write a program to demonstrate the concept of default constructor,
parameterized constructor, copy constructor & destructor.
A) Default Constructor
OUTPUT
B) Parameterised Constructor
OUTPUT
C) Copy Constructor
OUTPUT
D) Destructor
OUTPUT
OUTPUT
Q 10. Create a class polar having data members - radius and angle. It
contains member function for taking input data member & for displaying
value of data members. Class polar contains declaration of friend function
add which accepts two objects of class polar and returns object of class
polar after addition.
OUTPUT
Q 11. Write a program to design a class complex to represent complex
numbers. Perform addition & multiplication of complex numbers by
overloading + & * operators (use friend function).
OUTPUT
Q 12. Create a class circle with data member radius. Provide member
function to calculate area. Derive a class sphere from a class circle.
Provide member function to calculate volume. Derive class cylinder from
class sphere with additional data member for height and member
function to calculate volume.
OUTPUT
Q 13. Design three classes: student, exam & result. The student class has
data members - roll no, name of student. Create a class exam, which
contains data members - name of subject, minimum marks, maximum
marks, obtained marks for three subjects. Derive class result from both
the students and exam classes.
OUTPUT
Q 14. Define an abstract class shape which has a pure virtual function
area(). Derive two classes – rectangle & triangle that will implement the
area().
OUTPUT
Q 15. Write a program to demonstrate the concept of virtual function.
OUTPUT
Q 16. Write a program to copy the contents of one file to another.
OUTPUT
Q 17. Write a program to count the number of lines and words in a file
and display on the screen.
OUTPUT
Q 18. Write a program to enter a string, then write it to the file character
by character and read from file character by character.
OUTPUT
Q 19. Write a program to show the concept of exception handling which
throws a division by zero exception and catches it in the catch block.
OUTPUT
Q 20. Write a program that uses function template to find the largest and
smallest value.
OUTPUT
Q 21. Write a program that uses function template to swap two values.
OUTPUT