C++ Practical File (3sem)
C++ Practical File (3sem)
C++ Practical File (3sem)
Session (2020-2023)
A practical file on
C++ Lab
(Paper Code: - BCA 253)
DATA MEMBERS
- name of depositor
- account number
- type of account
- balance amount
MEMBER FUNCTIONS
- to assign initial values
- to deposit amount
- to withdraw amount after checking the
balance
- to display name and balance
Program
2
Output
Q2. Write a program for creating a class employee that holds information like
empid, name, designation, HRA, basic salary & age. The class should perform
operations like entering the details of the employee, calculating its total salary
and printing all the employee details.
Program
Output
Q3. Write a program to show the concept of returning object to the function.
Program
Output
Q4. Write a program to dynamically allocate & deallocate memory using new
& delete operator.
Program
Output
Q5. Write a program using inline function to find minimum of two values.
Program
Output
Q6. Write a program to calculate the area of rectangle, square, triangle &
circle using the concept of function overloading.
Program
Output
Q7. Write a program to perform addition of time in the hours and minutes
format using the concept of classes & objects.
Program
Output
Q8. Write a program to demonstrate the concept of default constructor,
parameterized constructor, copy constructor & destructor.
#1 Default Constructor: -
Program
Output
#2 Parameterized Constructor: -
Program
Output
#3 Copy Constructor
Program
Output
#4 Destructor
Program
Output
Q9. Write a program to create class distance having data members - feet and
inch (a single object will store distance in form such as 5 feet 3 inch). It
contains a member function for taking input the data members and another
member function for displaying value of data members. Class distance
contains declaration of friend function add which accepts two objects of class
distance and returns object of class distance after addition. Test the class
using main function and objects of class distance.
Program
Output
Q10. 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.
Program
Output
Q11. Write a program to design a class complex to represent complex
numbers. Perform addition & multiplication of complex numbers by
overloading + & * operators (use friend function).
Program
Output
Q12. 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.
Program
Output
Q13. 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.
Program
Output
Q14. Define an abstract class shape which has a pure virtual function area().
Derive two classes – rectangle & triangle that will implement the area().
Program
Output
Q15. Write a program to demonstrate the concept of virtual function.
Program
Output
Q16. Write a program to copy the contents of one file to another.
Program
Output
Q17. Write a program to count the number of lines and words in a file and
display on the screen.
Program
Output
Q18. Write a program to enter a string, then write it to the file character by
character and read from file character by character.
Program
Output
Q19. Write a program to show the concept of exception handling which
throws a division by zero exception and catches it in the catch block.
Program
Output
Q20. Write a program that uses function template to find the largest and
smallest value.
Program
Output
Q21. Write a program that uses function template to swap two values.
Program
Output