0% found this document useful (0 votes)
50 views7 pages

Procedure

Uploaded by

amariammal985
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views7 pages

Procedure

Uploaded by

amariammal985
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Procedure

AAD and OOPS lab


Ex:1
Aim:
To Write a program to solve the tower of Hanoi using recursion.
Procedure:
Step 1: Import Required Header Files
Step 2: Define the Hanoi() Function
● This function returns how the disk is placed from A to C
Step 3:write the Main Function
Step 4:Save the program with .cpp extension
Step 5: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:2
Aim:
To Write a program to traverse through binary search tree using traversals.
Procedure:
Step 1: Import Required Header Files
Step 2:Define Node Structure:
Step 3: write function for In-order Traversal:
It Returns operation of In-Order traversal
Step 4: write function for Post-order Traversal:
It Returns operation of Post-Order travesal
Step 5: write function for Pre-order Traversal:
It Returns operation of Pre-Order traversal
Step 6:write the Main Program:
Step 7:Save the program with .cpp extension
Step 8: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:3
Aim:
To Write a program to perform various operations on stack using linked list.
Procedure:
Step 1: Import Required Header Files
Step 2:Define Node Structure:
Step 3: Write a class named stack which contains data members and three
methods pop(),push(),display().
Step 4:write the Main Program:
Step 5:Save the program with .cpp extension
Step 6: Clear the errors and run the programm using ctrl+F9Bottom of Form
Ex:4
Aim:
To Write a program to perform various operation in circular queue.
Procedure:
Step 1: Import Required Header Files
Step 2: Write a class named circularqueue which contains data members
and three methods enqueue(),dequeue(),display()
Step 3:write the Main Program:
Step 4:Save the program with .cpp extension
Step 5: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:5
Aim:
To Write a program to sort an array of an elements using quick sort.
Procedure:
Step 1: Import Required Header Files
Step 2: Write the function swap to swap numbers
Step 3:Write the function partition to make partition
Step 4:write the function quicksort to sort
Step 5:write the function to print array
Step 6:write the Main Program:
Step 7:Save the program with .cpp extension
Step 8: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:6
Aim:
To Write a program to solve number of elements in ascending order using
heap sort.
Procedure:
Step 1: Import Required Header Files
Step 2: Write the function heapify
Step 3:write the function heapsort to sort
Step 4:write the function to print array
Step 5:write the Main Program:
Step 6:Save the program with .cpp extension
Step 7: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:7
Aim:
To Write a program to solve the knap sack problem using greedy method
Procedure:
Step 1: Import Required Header Files
Step 2:write the Main Program to get the input and calculate the maximum
total value of the knapsack
Step 3:Save the program with .cpp extension
Step 4: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:8
Aim:
To Write a program to search for an element in a tree using divide& conquer
strategy.
Procedure:
Step 1: Import Required Header Files
Step 2:Define Node Structure:
Step 3: Write the function to insert node
Step 4:Write the function to search value from the tree
Step 5:write the function to delete the tree
Step 6:write the Main Program
Step 7:Save the program with .cpp extension
Step 8: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:9
Aim:
To Write a program to place the 8 queens on an 8X8 matrix so that no two
queens Attack.
Procedure:
Step 1: Import Required Header Files
Step 2:Define Node Structure:
Step 3: Write the function issafe to check one queen do not attack another
queen
Step 4:Write the function solveNqueen to solve the Nqueen problem
Step 5:write the Main Program
Step 6:Save the program with .cpp extension
Step 7: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:10
Aim:
To Write a C++ program to perform Virtual Function
Procedure:
Ex:11
Aim:
To Write a C++ program to perform Parameterized constructor
Procedure:
Step 1: Import Required Header Files
Step 2:Create a class named animal
Step 3: Write a virtual method named sound()
Step 4:Write a derieved class named dog
Step 5:write the virtual method sound() in derieved class dog
Step 6:Write a derieved class named cat
Step 7:write the virtual method sound() in derieved class cat
Step 8:write the Main Program:
Step 9:Save the program with .cpp extension
Step 10: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:12
Aim:
To Write a C++ program to perform Friend Function
Procedure:
Step 1: Import Required Header Files
Step 2:Create a class named rectangle
Step 3: Write data members as length and float
Step 4:Write parameterized constructor
Step 5:write the method area(),perimeter(),display()
Step 6:write the Main Program
Step 7:Save the program with .cpp extension
Step 8: Clear the errors and run the program using ctrl+F9Bottom of Form
Ex:13
Aim:
To Write a C++ program to perform Function Overloading
Procedure:
Step 1: Import Required Header Files
Step 2: Define the First add() Function
● This function takes two integer parameters and calculates their sum.
Step 3: Define the Second add() Function
● This overloaded function takes three integer parameters and
calculates their sum.
Step 4:write the Main Function
Step 5:Save the program with .cpp extension
Step 6: Clear the errors and run the program using ctrl+F9Bottom of Form

Ex:14
Aim:
To Write a C++ program to perform Single Inheritance
Procedure:
Step 1: Import Required Header Files
Step 2: Define the Animal Base Class contains two public methods eat()
and sleep()
Step 3: Define the Dog Derived Class contains one additional method bark()
Step 4: Write the Main Function
Step 5:Save the program with .cpp extension
Step 6: Clear the errors and run the program using ctrl+F9
Ex:15
Aim:
To Write a C++ program to perform Employee Details using files.
Procedure:
Step 1: Import Required Header Files
Step 2: Define the Employee Class contains four private members,Two
public methods getDetails() and writeToFile().
Step 3: Define the getDetails() Method
This method collects employee details from the user.
Step 4: Define the writeToFile() Method
This method opens a text file (emp_details.txt) in append mode and writes
the employee details into the file.
Step 5: Write the Main Function
Step 6:Save the program with .cpp extension
Step 7: Clear the errors and run the program using ctrl+F9

You might also like