Académique Documents
Professionnel Documents
Culture Documents
LAB MANUAL CS2209 OBJECT ORIENTED PROGRAMMING LAB YEAR : II Yr B.E CSE SEMESTER : 3
LAB MANUAL
Sub Code & Name: CS2209 OBJECT ORIENTED PROGRAMMING LAB Branch: CS Semester: 3
LIST OF EXPERIMENTS :-
CYCLE I
IMPLEMENTATION IN C++
EX NO : 1
A) Income Tax Calculation Using Default Arguments B) Categorizing Employees Based On Designation Using Static Members C) Addition Of Two Private Data Members Using Friend Functions Matrix Vector Multiplication Manipulation Of Complex Numbers Using Operator Overloading And Type Conversions Matrix Manipulation Using Dynamic Memory Allocation Overloading New And Delete Operators Implementation Of Linked List Using Templates CYCLE II
EX NO : 2 EX NO : 3 EX NO : 4 EX NO : 5 EX NO : 6
EX NO : 7
A) Implementation Of Bubble Sort And Insertion Sort Using Templates B) Implementation Of Quik Sort And Merge Sort Using Templates Implementation Of Stack And Queue Using Exception Handling
EX NO : 8
EX NO : 9 Implementation Of Minimum Spanning Tree Using Inheritance EX NO : 10 Dynamic Polymorphism And RTTI EX NO : 11 Manipulation Of Complex Numbers Using File Functions
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 1a Branch: CS Semester: 3
NAME : Ramu SALARY : Rs.15000 INCOME TAX : Rs. 7500 MENU --------1. Default tax percentage calculation 2. Getting tax percentage from the user 3. Exit Enter the option = 2 Enter the name Enter the salary amount : Samuel : Rs. 15000
Enter the tax percent NAME : Samuel SALARY : Rs.15000 INCOME TAX : Rs. 750
: 0.05
MENU --------1. Default tax percentage calculation 2. Getting tax percentage from the user 3. Exit Enter the option = Press any key to continue!!!
Result: Thus a C++ program for calculating income tax using default arguments has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB
Exercise : 1b
Branch:
CS
3. Total Employees 4. Exit Enter the option = 1 EMPLOYEE ID : 5001 NAME EMPLOYEE ID : 5003 NAME : Ramu
: Sankar = 2
The total number of managers MENU --------1. Managers List 2. Engineers List 3. Total Employees 4. Exit Enter the option = 2 EMPLOYEE ID : 5002 NAME
: Ramnaresh
The total number of engineers = 1 MENU --------1. Managers List 2. Engineers List 3. Total Employees 4. Exit Enter the option = 3 The total number of employees = 3
Result: Thus
C++
program
to
categorize
employees
based
on
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 1c Branch: CS Semester: 3
Result: Thus a C++ program for adding two private data members using friend functions has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 2 Branch: CS Semester: 3
= =
1 2
= = = =
3 4 5 6
Resultant Matrix -------------------13 16 MATRIX MULTIPLICATION -------------------------------------1. Row Matrix 2. Column Matrix 3. Exit Enter the option = 2 Enter the rows and columns for the 1st matrix = 2 Enter the rows and columns for the 2nd matrix = 2 Enter A matrix -----------------Enter the value of a[0][0] Enter the value of a[0][1] Enter B matrix ----------------Enter the value of Enter the value of Enter the value of Enter the value of
= =
1 2
= = = =
3 4 5 6
Resultant Matrix -------------------3 4 6 8 MATRIX MULTIPLICATION -------------------------------------1. Row Matrix 2. Column Matrix 3. Exit Enter the option = 3 Press any key to continue!!!
Result: Thus a C++ program to implement matrix vector multiplication using friend functions has been executed successfully.
C/MN/01/28.02.02
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise : 3 Branch: CS Semester : 3
MENU -------1. Addition 2. Subtraction 3. Integer to Complex 4. Complex to Integer 5. Double to Complex 6. Complex to double 7. Exit Enter the option = Enter the real and Enter the real and Difference = -8 + 2 imaginary part : imaginary part : i2 7 + i12 15 + i10
MENU -------1. Addition 2. Subtraction 3. Integer to Complex 4. Complex to Integer 5. Double to Complex 6. Complex to double 7. Exit Enter the option = 3 Enter the number to be converted = 10 The number in complex form is = 10 + i0 MENU -------1. Addition 2. Subtraction 3. Integer to Complex 4. Complex to Integer 5. Double to Complex 6. Complex to double 7. Exit Enter the option = 4 Enter the real and imaginary part = 30 The number in integer form is = 30 15
Result: Thus a C++ program to manipulate complex numbers using operator overloading and type conversions has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 4 Branch: CS Semester: 3
= = = =
5 6 8 10
= = = =
2 7 12 15
3. Exit Enter the option = 1 RESULTANT MATRIX ----------------------------7 13 20 25 MENU -------1. Addition 2. Subtraction 3. Exit Enter the option = 2 RESULTANT MATRIX ----------------------------3 -1 -4 -5 MENU -------1. Addition 2. Subtraction 3. Exit Enter the option = 3 Press any key to continue!!!
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 5 Branch: CS Semester: 3
overloading new and delete operators. Algorithm: 1. Start 2. Get the rollno, name and the marks in each subject from the user. 3. Overload new operator to allocate space for name and marks. 4. In the sum function calculate the marks. 5. Display the student details finally. 6. Finally delete the space allocated for name and marks by overloading delete operator. 7. Stop. Sample input and output: OVERLOADING NEW AND DELETE OPERATORS ------------------------------------------------------------------Enter the Roll no = 36 Enter the Name = Guruprasad Enter the marks one by one 98 96 95 99 93 STUDENT MARK LIST -----------------------------ROLL NO : 36 NAME : Guruprasad TOTAL : 481
Result: Thus a program to calculate student marks by overloading new and delete operators has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 6 Branch: CS Semester: 3
Enter the number (Press 999 for the end) = 60 Enter the number (Press 999 for the end) = 999 LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 1 Enter the position in which the number is to be inserted = 3 Enter the number to be inserted = 25 LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 3 10202530405060END LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 2 Enter the position of the node to be deleted = 7 LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 3 102025304050END LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 4 Datatypes -----------1. Integer 2. Floating Point 3. Exit Enter the option = 2
CREATION Enter the Enter the Enter the Enter the Enter the Enter the Enter the
= = = = = = =
LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 1 Enter the position in which the number is to be inserted = 3 Enter the number to be inserted = 25.26 LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 3 10.5620.2325.2630.1440.1850.8960.54END LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 2 Enter the position of the node to be deleted = 7 LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 3 10.5620.2325.2630.1440.1850.89END LINKED LIST MENU -------------------------1. INSERTION 2. DELETION 3. DISPLAY 4. EXIT Enter the option = 4 Datatypes
-----------1. Integer 2. Floating Point 3. Exit Enter the option =3 Press any key to continue!!!!!!!!
Result: Thus a template to implement linked list class and its method has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 7a Branch: CS Semester: 3
SORTING OPTIONS -------------------------1. Bubble Sort 2. Insertion Sort 3. Exit Enter the option = 3 DATATYPES ----------------1. Integer 2. Floating point 3. Exit Enter the option = 2 SORTING OPTIONS -------------------------1. Bubble Sort 2. Insertion Sort 3. Exit Enter the option = 2 Enter no of terms = 6 Enter the numbers 5.62 6.14 5.54 2.17 The sorted array is 2.17 3.55 4.89 5.54
3.55 5.62
4.89 6.14
Result: Thus the program to implement bubble sort and insertion sort using templates has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 7b Branch: CS Semester: 3
SORTING OPTIONS -------------------------1. Quick Sort 2. Merge Sort 3. Exit Enter the option = 3 DATATYPES ----------------1. Integer 2. Floating point 3. Exit Enter the option = 2 SORTING OPTIONS -------------------------1. Quick Sort 2. Merge Sort 3. Exit Enter the option = 2 Enter no of terms = 6 Enter the numbers 5.62 6.14 5.54 2.17 The sorted array is 2.17 3.55 4.89 5.54
3.55 5.62
4.89 6.14
Result: Thus the program to implement quick sort and merge sort using templates has been executed successfully.
LAB MANUAL
Sub Code & Name : CS2209 OBJECT ORIENTED PROGRAMMING LAB Exercise: 8 Branch: CS Semester: 3
--------1. Push 2. Pop 3. Top 4. Display 5. Exit Enter the option = 1 Enter the element = 20 MENU --------1. Push 2. Pop 3. Top 4. Display 5. Exit Enter the option = 1 Enter the element = 30 MENU --------1. Push 2. Pop 3. Top 4. Display 5. Exit Enter the option = 1 Stack is Full!!! MENU --------1. Push 2. Pop 3. Top 4. Display 5. Exit Enter the option = 4 30 20 10 MENU --------1. Push 2. Pop 3. Top 4. Display 5. Exit Enter the option = 2 The popped element is 30 MENU --------1. Push 2. Pop 3. Top 4. Display 5. Exit Enter the option = 5 EXCEPTION HANDLING --------------------------------
1. Stack 2. Queue 3. Exit Enter the option = 2 QUEUE ---------Enter the number of elements = 3 MENU --------1. Enqueue 2. Dequeue 3. Exit Enter the option = 2 Queue is empty MENU --------1. Enqueue 2. Dequeue 3. Exit Enter the option = 1 Enter the element = 5 MENU --------1. Enqueue 2. Dequeue 3. Exit Enter the option = 1 Enter the element = 10 MENU --------1. Enqueue 2. Dequeue 3. Exit Enter the option = 1 Enter the element = 15 MENU --------1. Enqueue 2. Dequeue 3. Exit Enter the option = 1 Queue is Full!! MENU --------1. Enqueue 2. Dequeue 3. Exit Enter the option = 3 Result: Thus the program to implement stack and queue using exception handling has been executed successfully.