Lab Programs
Basic Programs
- Print hello world message.
- Create four function calculators for fractions.
- Write a program that takes length as input in feet and inches. The program should then convert the lengths in centimeters and meters and display it on screen.
- Print the largest among three integer numbers.
Constructors
- Create a class student to store and print the details of student inside a class.
- Display odd and even numbers upto a set limit “n” by defining member functions to display even and odd numbers outside the class.
- Define a class to represent a bank account. Include the following member
- Data Members
Account No
Name
Type
Balance - Member Functions
Deposit an amount
Withdraw an amount
To display name and balance
- Execute Program to create a bank account using initial amount of Rs 500 and perform all the operations – deposit, withdraw and balance using default and parameterized constructor. Also create an array of object.
Function & Operator Overloading
- Create class average and member functions setvalue() and mean() where setvalue() initializes values of a and b .mean() calculates the mean of two numbers and arguments to function mean() is the object of class average. Display the mean value.
- Write an overloaded function to calculate and return the area of a square, a circle, a rectangle. Then call it from the main function
- Overload unary minus , ++ ,= = ,and > .
- Overload = and + in a string operation.
- Overload binary operator + while adding complex numbers
- Overload + operator to concatenate two strings.
- Write a program to demonstrate this pointer.
Friend Function
- Create a Box class which contains width and height. Using a Friend function print the width of the box object.
Inheritance
- Create a class student and include data member roll_number. Derive a class test from student base class to include member function marks(x,y).Create class sports with member function get_score.The class result is derived from base classes test and sports that sums the values of x,y and score.
- Create object of derived class and invoke all member functions to illustrate multilevel and multiple inheritance.
Virtual Functions
- Implement the concept of Virtual functions
- Implement pure virtual function and abstract class.
Exceptions and File handling
- Implement the exception.
- Program to read details of employees from terminal and display them by creating files.