×
Don't wait for the right time for studying... It won't come.
--Your friends at LectureNotes
Close

Programming And Datastructure

by Anna Superkings
Type: PracticalInstitute: Anna university Specialization: Computer Science EngineeringViews: 26Uploaded: 2 months agoAdd to Favourite

Touch here to read
Page-1

Programming And Datastructure by Anna Superkings

Experiment:
Anna Superkings
Anna Superkings

/ 68

Share it with your friends

Suggested Materials

Leave your Comments

Contributors

Anna Superkings
Anna Superkings
Department of Computer Science and Engineering CS6311 PROGRAMMING AND DATA STRUCTURES II LABORATORY III SEMESTER/ II YEAR CS6311 PROGRAMMING AND DATA STRUCTURE LABORATORY II SYLLABUS OBJECTIVES: The student should be made to: • • • Be familiarized with good programming design methods, particularly Top- Down design. Getting exposure in implementing the different data structures using C++ Appreciate recursive algorithms. LIST OF EXPERIMENTS: IMPLEMENTATION IN THE FOLLOWING TOPICS: 1. Constructors & Destructors, Copy Constructor. 2. Friend Function & Friend Class. 3. Inheritance. 4. Polymorphism & Function Overloading. 5. Virtual Functions. 6. Overload Unary & Binary Operators Both as Member Function & Non Member Function. 7. Class Templates & Function Templates. 8. Exception Handling Mechanism. 9. Standard Template Library concept. 10. File Stream classes. 11. Applications of Stack and Queue
CS6311-PDS II LAB MANUAL 12. Binary Search Tree 13. Tree traversal Techniques 14. Minimum Spanning Trees 15. Shortest Path Algorithms TOTAL: 45 PERIODS OUTCOMES: At the end of the course, the student should be able to: • • • • Design and implement C++ programs for manipulating stacks, queues, linked lists, trees, and graphs. Apply good programming design methods for program development. Apply the different data structures for implementing solutions to practical problems. Develop recursive programs using trees and graphs. 2
CS6311-PDS II LAB MANUAL EX NO: 1 SIMPLE C++ PROGRAM AIM: To implement a simple C++ program to display the name and number ALGORITHM: Step 1: Step 2: Step 3: Step 4: Step 5: Include the header files Declare the class as person with data members name and number Create an object for the class person Get the name and number as input Access the data member using object and display the output. PROGRAM: #include <iostream.h> #include<conio.h> using namespace std; class person { public: string name; int number; }; int main() { person obj; cout<<"Enter the Name :"; cin>>obj.name; cout<<"Enter the Number :"; cin>>obj.number; cout << obj.name << ": " << obj.number << endl; getch(); return 0; } SAMPLE OUTPUT: Enter the Name: Byron Enter the Number: 100 Byron: 100 RESULT: Thus the simple C++ program to display the name and number is implemented successfully. 3
CS6311-PDS II LAB MANUAL EX NO: 2 CONSTRUCTOR AIM: To implement a C++ program to calculate prime number using Constructor. ALGORITHM: Step 1: Include the header files Step 2: Declare the class as Prime with data members and Member functions. Step 3: Consider the argument constructor Prime () with integer Argument. Step 4: To cal the function calculate () and do the following steps. Step 5: For i=2 to a/2 do Step 6: Check if a%i==0 then set k=0 and break. Step 7: Else set k value as 1. Step 8: Increment the value i as 1. Step 9: Check whether the k value is 1 or 0. Step 10: If it is 1 then display the value is a prime number. Step 11: Else display the value is not prime. PROGRAM: #include<iostream.h> #include<conio.h> using namespace std; class prime { int a,k,i; public: prime(int x) { a=x; } void calculate() { k=1; { for(i=2;i<=a/2;i++) if(a%i==0) { k=0; break; } else { k=1; } } } void show() 4

Lecture Notes