Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SYLLABUS
Task-1
Write C++ program to implement the following
a) Constructors and destructors
b) Overloading constructors
Task2
Write C++ program to implement the following variations of
Friend Concepts
a) External Function declared as Friend
b) Member Function declared as Friend
c) One Class declared as Friend of another class.
Task-3
Write C++ program to implement the following
a) Function and Operator Overloading
b) Function and Operator Overloading using FRIEND concept
Task-4
Write C++ program to implement Function and Class Templates
Task-5
Write a C++ program to implement
a) Single Inheritance
b) Multiple Inheritance
c) Multilevel Inheritance
d) Hybrid Inheritance
Task-6
Write C++ program to implement Runtime Polymorphism.
Task-7
Write C++ program to implement the
a) Merge sort
b) Heap sort
Task-8
Write a C++ program to implement Open addressing collision
resolution strategies of Hashing
a) Linear probing
b) Quadratic probing
c) Double Hashing
Task-9
Write a C++ program to perform the following operations:
a) Insert an element into a binary search tree.
b) Delete an element from a binary search tree.
c) Search for a key element in a binary search tree.
Task-10
Write C++ programs to implement Non-Recursive Tree Traversal
techniques
a) Preorder
b) Inorder
c) Postorder.
Task-11
Write C++ program to perform the following operations on
AVLtree
a) Insert an element
b) Delete an element from AVLtree
c) Search for a key element in an AVLtree
Task-12
Write C++ programs to Implement Graph Traversal Techniques
a) BFS
b) DFS.
DS THROUGH C++ LAB PROGRAMS
Task-1
1. TO IMPLEMENT DEFAULT CONSTRUCTORS WITH (OR) WITHOUT ARGUMENTS
#include<iostream>
class area
int l,b,h;
public:
area()
cout<<"default constructor";
l=0;b=0;h=0;
area(int i, int j)
l=i;b=j;
l=x;b=y;h=z;
void display()
{
cout<<"\n\t l="<<l<<"b="<<b<<"h="<<h;
};
int main()
area a=area();
a.display();
area b=area(10,20);
b.display();
area c=area(10,20,30);
c.display();
}
OUTPUT:
default constructor:
l=0 b=0 h=0
constructor with two arguments:
l=10 b=20
constructor with three arguments:
l=10 b=20 c=30
#include<iostream>
class area
int a;
public:
area(int b)
{
a=b;
a=a1.a;
void display()
cout<<a;
};
int main()
area a1(10);
area a2(a1);
a1.display();
cout<<"value of a in a2";
a2.display();
}
OUTPUT:
value of a in a1:10
value of a in a2:10
class area
{
public:
area(float radius);
};
area::area(float radius)
int main()
area circle(2.1);
area rectangle(2,3);
area cube(2,3,4);
OUTPUT:
area if circle is:13.851809
area of rectangle is:6
area of cube is:24
4. TO IMPLEMENT DESTRUCTORS
#include<iostream>
int a=0;
class area
public:area()
a++;
cout<<"object"<<a<<" created";
public:~area()
cout<<"object"<<a<< "destroyed";
a--;
};
int main()
{
area a1,a2;
}
OUTPUT:
object 1 created
object 2 created
object 2 destroyed
object 1 destroyed
Task-2
class shape
int age;
char name[10];
public:
void set_val()
cout<<"\nEnter Values\n";
cout<<"\nEnter name\n";
cin>>name;
cout<<"\nEnter age\n";
cin>>age;
};
void display(shape s)
cout<<"\nName="<<s.name;
cout<<"\nAge="<<s.age;
int main()
shape sh;
sh.set_val();
display(sh);
Output:
Enter the name:Sandeep
Enter age:24
Name=Sandeep
Age=24
TASK-2
a) External Function declared as Friend
b) Member Function declared as Friend
c) One Class declared as Friend of another class.
Task-3
Write C++ program to implement the following
a) Function and Operator Overloading
b) Function and Operator Overloading using FRIEND concept
Task-4
Write C++ program to implement Function and Class Templates
Task-5
Write a C++ program to implement
a) Single Inheritance
b) Multiple Inheritance
c) Multilevel Inheritance
d) Hybrid Inheritance
Task-6
Write C++ program to implement Runtime Polymorphism.
Task-7
Write C++ program to implement the
a) Merge sort
b) Heap sort
Task-8
Write a C++ program to implement Open addressing collision
resolution strategies of Hashing
a) Linear probing
b) Quadratic probing
c) Double Hashing
Task-9
Write a C++ program to perform the following operations:
a) Insert an element into a binary search tree.
b) Delete an element from a binary search tree.
c) Search for a key element in a binary search tree.
Task-10
Write C++ programs to implement Non-Recursive Tree Traversal
techniques
a) Preorder
b) Inorder
c) Postorder.
Task-11
Write C++ program to perform the following operations on
AVLtree
a) Insert an element
b) Delete an element from AVLtree
c) Search for a key element in an AVLtree
Task-12
Write C++ programs to Implement Graph Traversal Techniques
a) BFS
b) DFS.