OBJECT-ORIENTED PROGRAMMING LAB MANUAL
I Year - II Semester
OBJECT-ORIENTED PROGRAMMING LAB
Exercise – 1 (Basics)
Write a Simple Program on printing “Hello World” and “Hello Name” where name is the input from
a) Convert any two programs that are written in C into C++
b) Write a description of using g++ (150 Words)
Exercise – 2 (Expressions Control Flow)
a) Write a Program that computes the simple interest and compound interest payable on
principal amount (in Rs.) of loan borrowed by the customer from a bank for a given r period of time
(in years) at specific rate of interest. Further determine whether the bank will benefit by charging
simple interest or compound interest.
b) Write a Program to calculate the fare for the passengers travelling in a bus. When a Passenger
enters the bus, the conductor asks “What distance will you travel?” On knowing distance from
passenger (as an approximate integer), the conductor mentions the fare to the passenger according to
Exercise – 3 (Variables, Scope, Allocation)
a) Write a program to implement call by value and call by reference using reference variable.
b) Write a program to illustrate scope resolution, new and delete Operators. (Dynamic Memory
c) Write a program to illustrate Storage classes
d) Write a program to illustrate Enumerations
Exercises –4 (Functions)
Write a program illustrating Inline Functions
a) Write a program illustrate function overloading. Write 2 overloading functions for power.
b) Write a program illustrate the use of default arguments for simple interest function.
Exercise -5 (Functions –Exercise Continued)
a) Write a program to illustrate function overloading. Write 2 overloading functions for adding two
b) Write a program illustrate function template for power of a number.
c) Write a program to illustrate function template for swapping of two numbers.
Exercise -6 (Classes Objects)
Create a Distance class with:
• feet and inches as data members
• member function to input distance
• member function to output distance
• member function to add two distance objects
a). Write a main function to create objects of DISTANCE class. Input two distances and output the
b). Write a C++ Program to illustrate the use of Constructors and Destructors (use the above
c) Write a program for illustrating function overloading in adding the distance between objects (use
the above problem)
d). Write a C++ program demonstrating a Bank Account with necessary methods and variables
Exercise – 7 (Access)
a) Write a program for illustrating Access Specifiers public, private, protected
b) Write a program implementing Friend Function
c) Write a program to illustrate this pointer
d) Write a Program to illustrate pointer to a class
Exercise -8 (Operator Overloading)
DMSSVH COLLEGE OF ENGINEERING