Laboratory Experiments
1.Write a C++ program to find the sum for the given variables using function with default arguments.
2. Write a C++ program to swap the values of two variables and demonstrates a function using call by value.
3. Write a C++ program the swap the values of two variables and demonstrates a function using Call by reference.
4. Write a program to find the largest, smallest & second largest of three numbers. (use inline function MAX and MIN to find largest & smallest of 2 numbers)
5. Write a program to calculate the volume of different geometric shapes like cube, cylinder and sphere and hence implement the concept of Function Overloading.
6. Write a C++ program to create a template function for Bubble Sort and demonstrate sorting of integers and doubles.
Laboratory Experiments
1. Define a STUDENT class with USN, Name, and Marks in 3 tests of a subject. Declare an array of 10 STUDENT objects. Using appropriate functions, find the average of the two better marks for each student. Print the USN, Name and the average marks of all the students.
2. Write a C++ program to create a class called COMPLEX and implement the following overloading functions ADD that return a complex number: (i) ADD (a, s2) – where ‘a’ is an integer (real part) and s2 is a complex number (ii) ADD (s1, s2) – where s1 and s2 are complex numbers.
3. Friend functions and friend classes: a) Write a program to define class name HUSBAND and WIFE that holds the income respectively. Calculate and display the total income of a family using Friend function. b) Write a program to accept the student detail such as name and 3 different marks by get_data() method and display the name and average of marks using display() method. Define a friend class for calculating the average of marks using the method mark_avg().
4. Create a class called MATRIX using two-dimensional array of integers. Implement the following operations by overloading the operator == which checks the compatibility of two matrices to be added and subtracted. Perform the addition and subtraction by overloading the + and – operators respectively. Display the results by overloading the operator <<. If (m1== m2) then m3 = m1+m2 and m4 = m1- m2 else display error.
5. Define a class SET with Data members: array of int, int variable to indicate number of elements in a SET object; and Member functions: to read element of a SET object, to print elements of a SET object, to find union of 2 objects of SET using operator overloading (S3=S1+S2), to find intersection of 2 objects of SET using operator overloading (S4= S1*S2). S1, S2, S3 and S4 are objects of SET. Use this class in a main function to show the above operations.
6. Write a program to create an HUMAN class with features Head, Legs, Hands.(NOTE: Head, Legs and Hands are of integer/float types) a. Create an object HUMAN1 using default constructor. (Default features to have 1 Head, 2 Legs and 2 Hands) b. Create an object HUMAN2 with customized inputs using Parameterized Constructor C. Create an object HUMAN3 using existing object HUMAN1 (Copy Constructor). D. Create an object HUMAN4 using Default Arguments Constructor (1 Head, 2 Legs and 2 Hands. E. All Humans die after their lifetime.(Destructor)
7. Demonstrate Simple Inheritance concept by creating a base class FATHER with data members FirstName, SurName, DOB and BankBalance and creating a derived class SON, which inherits SurName and BankBalance feature from base class but provides its own feature FirstName and DOB. Create and initialize F1 and S1 objects with appropriate constructors and display the Father & Son details.
8. Create an abstract base class EMPLOYEE with data members: Name, EmpID and BasicSal and a pure virtual function Cal_Sal().Create two derived classes MANAGER (with data members: DA and HRA and SALESMAN (with data members: DA, HRA and TA). Write appropriate constructors and member functions to initialize the data, read and write the data and to calculate the net salary. The main() function should create array of base class pointers/references to invoke overridden functions and hence to implement run-time polymorphism.
9. I/O streams and functions. Write a program to implement FILE I/O operations on characters. I/O operations includes inputting a string, Calculating length of the string, Storing the string in a file, fetching the stored characters from it, etc.
10. Write a program to implement Exception Handling with minimum 5 exceptions Classes including two built-in exceptions.
11. Write a program to concatenate 2 strings using STL String class functions.
12. Write a simple C++ program to store and display integer elements using STL Vector class.
Note 1: InthepracticalExaminationeachstudent has to pick onequestionfromPART-A and PART-Beach.
Note 2: Change of program is not permitted in the Practical Examination.