BCSL-032 Solved Lab Assignment | C++

These lab assignments are collected from IGNOU lab assignment book BCSL-032. You should solve these questions yourself then read the solutions presented here. Programs are tested on CodeBlock compiler.

C++ Lab Assignment

Session 1:

Problem 1. Write a program in C++ to find and print the all basic data types of C++ .  solution

Problem 2. Write a program in C++ to explain the use of for loop, while loop, switch-case, break and continue statements.  solution

Problem 3. Write a program in C++ to find the maximum mark, average- marks and minimum marks obtained by a student in five papers as given below:

Paper   Marks
Paper 1  50
Paper 2  70
Paper 3  65
Paper 4  80
Paper 5  56 solution

Problem 4. Write a program in C++ that : i) prints the factorial of a given number ii) prints weather a number is prime or not iii) generate a Fibonacci series of 20 numbers. solution

Session 2:

Problem 5. Write a C + + program to create Student class with appropriate constructor and destructor. Also show what happen when you try to access private data members from outside of the class.

Problem 6. Write a program in C + + to calculate the simple interest and compound interest for a given time period, given rate and for given principal amount using concept of class and member function.

Problem 7. Write a program in C + + to create an Employee class which read the following information from the keyboard:
Years of experience
and display it on screen using display_info() method.


Session 3:

Problem 8. Write a program in C + + with class Rectangle with the data fields width, length, area and color .The length, width and area are of double type and color is of string type .The methods are set_ length () , set_width (), set_ color(), and find_ area (). Create two object of Rectangle and compare their area and color. If area and color both are same for the objects then display “Matching Rectangles” otherwise display “Non matching Rectangle”.

Problem 9. Create a class Account with two overloaded constructors using C + + . First constructor is used for initializing, name of account holder, account number and initial amount in account. Second constructor is used for initializing name of account holder, account number, addresses, type of account and current balance. Account class is having methods Deposit (), Withdraw (), and Get_Balance().Make necessary assumption for data members and return types of the methods. Create objects of Account class and use them. Also create appropriate destructors for the Account class.

Problem 10.Write a program in C + + to create a Queue class with insert () and delete () methods. Create two objects of Queue with 10 data item in both.Also define a method to find queue length.

Session 4:

Problem 11. Write a program in C + + to create a data base with the following items by using structure/class:

Name of the patient
Bed number
Date of admission
List of Disease

Problem 12. Write a program in C + +  to create a Player class. Inherit classes  Cricket _Player, Football _Player and Hockey_ Player from Player  class. Create  appropriate constructors and destructors for these  classes.

Session 5:

Problem 13. Write a program in C + + to generate a database with the following details about the workers working in a manufacturing company, by using structure/class:

Problem 14. Write a class Book and derive classes ReferenceBook and Magazines from it. Every book has a price, title, author and ISBN number. Implement constructors, destructors and appropriate methods to manage a Book Store.

Problem 15. Write a C + + program to create Time class to implement the working of a normal watch by creating appropriate constructor, destructor and member function.

Session 6:

Problem 16. Write a program which read two number ax and y then perform the following function
a. x + y
b. x – y
c. x * y
d. x / y
Design the function x +y and x – y in base class and design the function x * y and x / y in derived class

Problem 17. Write a program in C + + which create Student class with method to Display_Grade and manage Attendance. Derive classes PG_Students and UG_Students from Student class.

Problem 18. Write a program by using inheritance to create the payroll of an organization by the following information:
Employee name
Employee Designation
Account Number
Date of Joining
Basic pay
Deduction (PF, PPF etc)

Session 7:

Problem 19. Write a C + + program to create a class called DATE. Accept two valid dates in the form dd/mm/yy. Implement the following operations by overloading the operators + and -. After every operation display the results by overloading the operator <<.
i. no_of_days=d1-d2; where d1 and d2 are DATE objects.d1>=d2 and no_of_days is an integer.
ii. d2=d1-no_of_days; where d1 is a DATE object and no_of_days is an integer.

Problem 20. 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.

Problem 21. Write a C + + program to create a class called MATRIX using a 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 operators + and – respectively. Display the results by overloading the operator<<.
display error

Session 8:

Problem 22. Write a program which designs two classes and the calculate the division of first class private data with second class private data by using concept of friend function.

Problem 23. Write a program to calculate following function by using the concept of virtual function. F(x) = 7×5 + 9×4 + 6×3 + 2×2 + 4

Session 9:

Problem 24-A. Write a C + + program to facilitate user to handle any chance of divide by zero exception.

Problem 24-B. Two vehicles are running on single track. If the vehicles are running in opposite direction there is a chance of collision. To avoid collisions write a C + + program using exception handling. You are free to make necessary assumptions.

Problem 25. Write a function template palindrome that takes a vector parameter and returns true or false according to whether the vector does not read the same forward as backward.

Problem 26. Create a C + + Template class for implementation of data structure Queue functionalities.

Session 10:

Problem 27. Implement the case study given in your course BCS-031 Block 3 Unit 4