OBJECT-ORIENTED PROGRAMMING LAB
Programmig:
Exercise – 1 (Basics)
Write a Simple Program on printing “Hello World” and “Hello Name” where name is the input
from the user
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)
b) WriteaProgramtocalculatethefareforthepassengerstravelinginabus. WhenaPassenger 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 following criteria.
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. (Dyanamic
MemoryAllocation)
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 numbers
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 sum.
b). Write a C++ Program to illustrate the use of Constructors and Destructors (use the
above program.)
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 BankAccount with necessary methods and variables
Exercise – 7 (Access)
Write a program for illustratingAccess Specifiers public, private, protected
a) Write a program implementing Friend Function
b) Write a program to illustrate this pointer
c) Write a Program to illustrate pointer to a class
d)
Exercise -8 (Operator Overloading)
a). Write a program to Overload Unary, and Binary Operators as Member Function, and Non
Member Function.
i. Unary operator as member function
ii. Binary operator as nonmember function
b). Write a c ++ program to implement the overloading assignment = operator
c).Write a case study on Overloading Operators and Overloading Functions (150 Words)
Exercise -9 (Inheritance)
a) Write C++ Programs and incorporating various forms of Inheritance
i) Single Inheritance
ii) Hierarchical Inheritance
iii) Multiple Inheritances
iv) Multi-level inheritance
v) Hybrid inheritance
b) Write a program to show Virtual Base Class
c) Write a case study on using virtual classes (150 Words)
Exercise-10 (Inheritance –Continued)
a) Write a Program in C++ to illustrate the order of execution of constructors and destructors in
inheritance
b) Write a Program to show how constructors are invoked in derived class
Exercise -11 (Polymorphism)
a) Write a program to illustrate runtime polymorphism
b) Write a program to illustrate this pointer
c) Write a program illustrates pure virtual function and calculate the area of different shapes
by using abstract class.
d) Write a case study on virtual functions (150 Words)
Exercise -12(Templates)
a) Write a C++ Program to illustrate template class
b) Write a Program to illustrate class templates with multiple parameters
c) Write a Program to illustrate member function templates
Exercise -13 (Exception Handling)
a).Write a Program for Exception Handling Divide by zero
b). Write a Program to rethrow an Exception
Exercise -14 (STL)
a) Write a Program to implement List and List Operations
b) Write a Program to implementVector andVector Operations
Exercise -15 (STLContinued)
a) Write a Program to implement Deque and Deque Operations
b) Write a Program to implement Map and Map Operations
Programmig:
Exercise – 1 (Basics)
Write a Simple Program on printing “Hello World” and “Hello Name” where name is the input
from the user
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)
b) WriteaProgramtocalculatethefareforthepassengerstravelinginabus. WhenaPassenger 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 following criteria.
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. (Dyanamic
MemoryAllocation)
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 numbers
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 sum.
b). Write a C++ Program to illustrate the use of Constructors and Destructors (use the
above program.)
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 BankAccount with necessary methods and variables
Exercise – 7 (Access)
Write a program for illustratingAccess Specifiers public, private, protected
a) Write a program implementing Friend Function
b) Write a program to illustrate this pointer
c) Write a Program to illustrate pointer to a class
d)
Exercise -8 (Operator Overloading)
a). Write a program to Overload Unary, and Binary Operators as Member Function, and Non
Member Function.
i. Unary operator as member function
ii. Binary operator as nonmember function
b). Write a c ++ program to implement the overloading assignment = operator
c).Write a case study on Overloading Operators and Overloading Functions (150 Words)
Exercise -9 (Inheritance)
a) Write C++ Programs and incorporating various forms of Inheritance
i) Single Inheritance
ii) Hierarchical Inheritance
iii) Multiple Inheritances
iv) Multi-level inheritance
v) Hybrid inheritance
b) Write a program to show Virtual Base Class
c) Write a case study on using virtual classes (150 Words)
Exercise-10 (Inheritance –Continued)
a) Write a Program in C++ to illustrate the order of execution of constructors and destructors in
inheritance
b) Write a Program to show how constructors are invoked in derived class
Exercise -11 (Polymorphism)
a) Write a program to illustrate runtime polymorphism
b) Write a program to illustrate this pointer
c) Write a program illustrates pure virtual function and calculate the area of different shapes
by using abstract class.
d) Write a case study on virtual functions (150 Words)
Exercise -12(Templates)
a) Write a C++ Program to illustrate template class
b) Write a Program to illustrate class templates with multiple parameters
c) Write a Program to illustrate member function templates
Exercise -13 (Exception Handling)
a).Write a Program for Exception Handling Divide by zero
b). Write a Program to rethrow an Exception
Exercise -14 (STL)
a) Write a Program to implement List and List Operations
b) Write a Program to implementVector andVector Operations
Exercise -15 (STLContinued)
a) Write a Program to implement Deque and Deque Operations
b) Write a Program to implement Map and Map Operations
No comments:
Post a Comment