C++ Lab R19
C++ Lab R19
C++ Lab R19
L T P C
SEMESTER-II
0 0 3 1.5
OBJECT ORIENTED PROGRAMMING THROUGH C++ LAB
COURSE OUTCOMES:
At the end of the Course, Student will be able to:
1. Able to differentiate structure oriented programming and object oriented programming.
2. Able to understand and apply various object oriented features.
3. Able to know concepts in operator overloading, function overloading & polymorphism.
4. Able to write, compile and debug programs in C++ language.
5. Design programs involving constructors, destructors.
6. Able to reuse of code using inheritance.
7. To implement the concept of files, templates and exceptions.
8. To write diversified solutions using C++ language.
EXERCISE-1(BASICS)
A. Write a CPP Program to swap two numbers using call by value, call by address, call by reference
and return by reference.
B. Write a CPP Program to calculate square and cube of a number using inline functions and
macros. (Demonstrate the use of inline functions compared to macros).
C. Write a CPP Program to find the area of a rectangle, a triangle and surface area of a sphere using
function overloading.
B.TECH/CSE/2019 (CBCS) 13
Swarnandhra College of Engineering & Technology - CBCS (Autonomous)
D. Write a CPP Program to declare all members of a class as public, Access the members using
objects. (Use public, protected, private).
E. Write a CPP Program to access the member functions inside and outside a class.
F. Write a CPP Program to access private data using non-member functions. (Use friend function).
G. Write a CPP Program to pass objects to functions by pass by value method.
H. Write a CPP Program to declare main () function as member function and overload it.
A. Write a CPP Program to show that “for each object constructors is called separately” and read
the values through keyboard (Use Constructor).
B. Write a CPP Program to create constructor with arguments and pass the arguments to
constructor.
C. Write a CPP Program to create object and release them using destructor.
D. Write a CPP Program to perform addition, subtraction, multiplication of two objects using
operator keyword.
E. Write a CPP Program to overload unary and binary operator overloading with friend function.
A. Write a CPP Program to derive a class publicly from base class. Declare base class members
under public, private and protected.
B. Write a CPP Program to derive single and multiple inheritances.
C. Write a CPP Program to declare virtual base class. Derive a class using two virtual classes.
D. Write a CPP Program to implementation of Virtual Function.
E. Write a CPP Program to Implementation of Pure Virtual Function.
A. Write a CPP Program to write and read text in a file. Use ofstream and ifstream classes.
B. Write a CPP Program to open a file for writing and reading purpose. Use open () function.
C. Write a CPP Program write text in a file. Read the text from the file from EOF. Display the
contents in reverse order.
D. Write a CPP Program to demonstrate that the data is read from file using ASCII format.
E. Write a CPP Program to find the factorial of a number. Throw multiple exceptions and define
multiple catch statements to handle exceptions.
F. Write a C++ Program to illustrate template class
Practice Programms
B.TECH/CSE/2019 (CBCS) 14
Swarnandhra College of Engineering & Technology - CBCS (Autonomous)
B.TECH/CSE/2019 (CBCS) 15
Swarnandhra College of Engineering & Technology - CBCS (Autonomous)
B.TECH/CSE/2019 (CBCS) 16
Swarnandhra College of Engineering & Technology - CBCS (Autonomous)
5. Exit
28. Write a C++ Program to Implement String in STL using following
1. Insert Substring in a String
2. Erase Substring from a String
3. Append Substring to a String
4. Replace the String with a Substring
5. Size of the String
6. Find substring in a String
7. Display the String
8. Exit
29. Write a C++ Program to Implement Array in STL using following
1. Insert Element into the Array
2. Size of the array
3. Front Element of Array
4. Element of Array
5. Display elements of the Array
6. Exit
30. Write C++ program to implement Bubble Sort using templates in C++
B.TECH/CSE/2019 (CBCS) 17