Looking for CS6311 / IT6311 Programming and Data Structure Lab II Important Questions? Read on to collect all important university questions for this subject under Anna University and its affiliated colleges.
Anna University , Chennai
Department of Computer Science Engineering
(Common to Information Technology)
CS6311 / IT6311 Programming and Data Structure Lab II
Important University Questions
Third Semester
2013 Regulation
CS6311: PROGRAMMING AND DATA STRUCTURES LABORATORY – II
1. Create a class Student with regno, name, CS1201, CS1202, CS1203 as data members. Include a member function to find the total and publish the result. Get minimum of five students' details and display the result in the form of list. Extend the Student into two different categories such as B.E and MCA Category B.E degree students have dept_name (CSE, ECE, EEE), dept_head, dept_location, core_subjects which is an array, subject_marks is an array containing the marks of the core subjects out of 100. Category MCA degree students have dept_name, dept_head, dept_location, core_subjects which is an array (whose size can be determined at the run time), subject_marks is an array containing the marks of the core subjects out of 100. Internal marks calculation is different for different categories of students. Internal marks (out of 100) for B.E students can be calculated as 50% of test1 + 50% of test2 (Considering two best tests out of three) Internal marks (out of 100) for MCA students can be calculated as 40% of test1 + 30% of test2 + 30% of test3 (Considering all the
three tests)
• Read and display the details of the Student with the operator overloading (<<, >>)
• Implement Calculate() in two different categories of the students and invoke them. (Use Virtual Function)
• Write the details of at least one category of the students in a binary file and show the details by reading from the file.
2. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
3. Develop a payroll application to compute the salary for the employees in an organization. Class Employee has general information namely employee_id, employee name, department_name, address, mobile number and email‐id. There are two types of employees such as training professionals and regular employees. The Definition of Pay_calculate() will be different for different types of employees. Include suitable menu for navigating the application. Training professionals has total teaching experience, qualification, no_of_sessions_handled. Salary = no_of_sessions_handled*one_day_salary (Both can be randomized values) Regular employees has department they belong to, basic_pay, designation Gross Pay = basic_pay+HRA+DA Net Pay = Gross Pay – PF HRA = 9% of Basic Pay, DA = 90% of Basic Pay, PF = 20% of Basic Pay
SNo Designation Basic_Pay
1 Manager 30000
2 Technical Lead 25000
3 Senior Software Engineer 20000
4 Software Engineer 15000
• Get and display details of different types of employees using operator overloading(<< , >>)
• Write suitable exceptions for the given scenario .
• Write a friend function LiseDeptWise() to list all employees for a given department_name.
4. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Prim’s Algorithm to construct minimum spanning tree.
5. Develop a banking application to computerize the operations in the bank. Account holder has general information that they require to provide are account_id, acct_holder_name, address, mobile number and email‐id. There are two types of account holders such as savings account & current account. Interest calculation definition will be different for different types of account holders. Include suitable menu for navigating the application.
o Savings account holder has purpose_of_account & balance
o Current savings account holder has type_of_business & balance
o Interest calculation will be done on the current balance.
o Interest calculation for savings account
o Interest = balance*8% of balance
o Interest calculation for current account
o Interest = balance*12% of balance
• Get and display details of different categories of account holders using operator overloading(<< ,>>)
• Write suitable exceptions for the given scenario .
• Implement the interest_calc method in two different types of account holders and invoke them. (Virtual Function)
6. Create a class BST with the data members node which is of type structure. This structure consists of the members element of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
Insert() – To insert an element into the binary search tree
Search() – To search for a given element in the tree
Inorder() – To perform inorder traversal for tree
FindMin() – To find the minimum element in the tree
7.Create class matrix with the data members 2D array, row and column of type integer. Overload the following operators and write the operator functions necessarily as member or friend of the class matrix.
>>(extraction operator) – to read the values for the data members
<< (insertion operator) – to display the values of the data members
+ (addition operator) ‐‐ to add two matrices
‐(unary minus) – to negate the values of a matrix
++(pre and post increment operator) – to increment the values of the data members of a matrix
Write the main() program to demonstrate the matrix object for unary and binary operator overloading.
8. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Prim’s Algorithm to construct minimum spanning tree.
9. Design a class Array as a template class with a single dimensional array and size of the array as data members. Template class need to work for different types of input (integer, float, char, char array, string, student, employee). Include the following member functions
‐ getArray() and printArray() to read and print the elements of the array
‐ sort()the array elements using bubble sort algorithm.
‐ To enable sorting employee or student objects based on a data member.
10. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the member functions to implement
• Adjacency matrix
• Dijkstra’s algorithm to solve the single source shortest path problem.
11. Create a class student with the data members roll number, name, marks array to hold marks for 5 subjects, total and a Boolean variable pass. Keep the following member functions in the class.
Void Read() – To read the data members
Void Print() – To print the data members
Void Result() – Computes the total and pass. Pass variable will be “true” if all the marks are >=50, otherwise, it is “false”.
Write a function template to sort the input values of type integer, float, char array, string and Student objects. Student objects need to be sorted based on their total.
• To sort integer, float and string values.
• To sort strings made up of character array.
• To sort student object based on the total.
12. A stack is a linear list of elements for which all insertions and deletions (usually accesses) are made at only one end of the list. Create a class with the data members integer array and the size. Write the following member functions and write menu driven () program to use those functions.
• Push (int X): pushes an element X on to the top of the stack – This function uses the IsFull() member function while pushing the data.
• int Pop(): pops the last pushed element. This function uses the IsEmpty() member function while popping the data from the stack .
• void Display(): to display the elements in the stack.
Write a program to find whether the given string is palindrome or not. (Use stack class).
13.Create a class Complex with the data members real and imaginary of integer type. Read two complex numbers and store them in a file. Write the following member functions.
• Read and print the complex numbers using stream operators. (<< , >>).
• Operator + () to perform complex number addition.
• Open the file, read complex numbers using input file stream and perform complex number addition.
• Store the resultant complex number in another file. (Use binary file stream).
14. Create a class BST with the data members node which is of type structure. This structure consists of the members of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
• Insert() – To insert an element into the binary search tree
• Preorder() – To perform preorder traversal for tree
• FindMax() – To find the maximum element in the tree
15. Create a class student with the data members roll number, name, marks array to hold the three UT marks for the subject PDS‐II, attendance (out of 5) and internal marks. Keep the following member functions in the class.
• To read and display the data members of student class.
• Compute_Internal() – Computes the internal marks.
• Create a binary file student.dat and insert 10 student objects in it.
• Find() – To find the student record given the position of it.
16. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
17. A Queue is a linear list of elements where an element will be inserted at the back end and deleted at the front end. Create a class queue with the data members integer array, front and rear. Include the following member functions in the class queue and write a menu driven (1. Insert, 2. Delete, 3. Display, 4. Exit) program to use the class queue.
Write suitable exceptions for the given scenario.
• bool IsEmpty(): return whether the queue is empty or not
• bool IsFull(): return whether the queue is full or not.
• Insert (int X): inserts an element X into the back end of the queue – This function uses the IsFull() member function while inserting the data.
• int Delete(): removes the element from the front end. This function uses the IsEmpty() member function while deleting the data from the queue.
• void Display(): to display the elements in the queue.
WWW.VIDYARTHIPLUS.COM
18. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• BFS() to perform breadth first search on the graph (use queue class).
19. Create a class person with a data member ‘namelist’ whose type is a double pointer. Memory space for this double pointer is allocated in the constructor of the class. Write a destructor to de‐allocate the memory of the character array. Include the following member functions:
• Read(), Disp() to read and display the data member ‘namelist’
• Create suitable constructor and destructor for the class person.
• Copy constructor to copy data members from one object to the other.
20. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
2 1. Consider an example of declaring the examination result. Design three classes: Student, Exam and Result.
The student class has data members such as roll number, name and address. Create the class Exam by inheriting the Student class. The Exam class adds data members to representing the marks scored in six subjects. Derive the Result class from the Exam class and it has its own data member ‘result’ which is of type bool. Include getResult() in Result class to set the corresponding value (true or false) based on the marks of the students given in Exam class.
Write an interactive program to model this relationship
Write a friend class to maintain the collection of result objects and include a member function to list the student details such as roll number, name, address, marks for six subjects based upon the result.
22. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Kruskal’s Algorithm to construct minimum spanning tree
23. Create a class called Circle with radius as data member and getCircle() and calcArea() as member functions to read the radius and calculate area of the circle.
Create a class called Cone which is derived from the Circle class. Utilize the data members and the member functions of the base class by the derived class to find the volume ((1/3)*3.14*r*r*h) of a cone. Create another class called Cylinder which is derived from the Circle class.
Utilize the data members and the member functions of the base class by the derived class to find the volume (3.14*r*r*h) of a cylinder.
• Get and retrieve the data members of cone and cylinder using operator overloading
• Use virtual function to find volume of the cone and cylinder and invoke them
24. Create a class BST with the data members node which is of type structure. This structure consists of the members element of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
• Insert() – To insert an element into the binary search tree
• Delete() – To delete a given element from the tree
• Preorder() – To perform preorder traversal for tree
25. Create a class matrix with the data members **m, row and column of type integer. Write the following member functions
• Overload stream operators (<<, >>) to read and display the matrix
• Overload binary minus (‐) operator to subtract one matrix from the other
• Overload unary minus (‐) operator to subtract the values of the elements of a given matrix
• Allocate memory for the data member ‘m’ using constructor
• Deallocate the memory for ‘m’ using destructor
26. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix
• DFS() to perform depth first search on the graph
27.Write a program to create a list container to maintain a set of integer elements and employee objects where an employee object consists of the data members name and empno. Implement the following
• Create a list of integer elements into the list container
• Insert into a list with the new element in the given required position
• Create a list of employee objects into the list container
• Insert into a list with a new employee object in the given required position
• Display the list the employee objects from the List container
28. Create a class BST with the data members node which is of type structure. This structure consists of the members of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
• Insert() – To insert an element into the binary search tree
• Delete() – To delete a given element from the tree
• Postorder() – To perform postorder traversal for tree (
29. Create a class Time to display a time value with the data members of hours, minutes and seconds. Include the following member functions to get and display the time separated by: (HH:MM:SS). Assume the time is represented in 12 hours.
If the input value exceeds the hour, minute and second then your function should report the exception as invalid hour/minute/second.
Write an operator function binary minus (‐) to find which time is later. For example invoking T1‐T2 displays T1 is later or T2 is later
30. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the member functions to implement
• Adjacency matrix creation
• Kruskal’s Algorithm to construct minimum spanning tree
3 1. Create a class Student with the data members rollno, *name, mark array containing marks for maths and science subjects and cutoff mark.
Include member function calculate_cutoff() to find cutoff where cut off mark is calculated as ((maths+science)/200)*80.
Create another class Sports with the data members name, level, sports_mark. Level data member
represents the national or international level player. Include member function calculate_sportsmark() to assign sports_mark to be 10 if national player, otherwise 20.
Create another class Sports_Student derived from both the student and the sports with data member
total_cutoff and calculate total_cutoff() to add the cutoff and the sports_mark.
• Write suitable exceptions for the given scenario
• Allocate memory for the data member ‘m’ using constructor
• Deallocate the memory for ‘m’ using destructor
32. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
33. Write a program to create a map container to maintain a set of key, value pairs, where key is integer element and student object and value is the GATE score (out of 100). Student object has the data members rollno and name. Display the elements of the map container.
• Create a map container with 10 key,value pairs where key is the integer element and value is the GATE score
• Display the integer key, value pairs from the Map container
• Create a map container with 10 key, value pairs where key is the student object and the value is the GATE score
• Display the student key, value pairs from the Map container
34. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Floyd‐Warshall algorithm to find the shortest path between every pair of vertices in the graph
35. Create a class employee with the data member empno. Create a class gross_salary which is derived from employee with the data members basic_pay, DA (92% of basic_pay), HRA (22% of basic_pay)of type float and the member function to compute gross_pay (i.e basic_pay + DA + HRA). Another class deduction that is derived from employee has the data members PF, medi_claim and the member function to compute deducted_amount (i.e PF + medi_claim). A class net_salary that is derived from both gross_salary and deduction has the data member net_pay and the member function to compute net_pay (i.e gross_pay ‐ deducted_amount).
• Model this hierarchy using inheritance
• Read and display the data members for the object result (use operator (<<, >>) overloading)
• Write compute_total() to find the total marks by adding part1, part2 and sports_mark
• Write suitable exceptions for the given scenario
36. Create a class Graph with the data member 2D array and the number of nodes of type integer. Write the member functions to implement
• Adjacency matrix creation
• Kruskal’s Algorithm to construct minimum spanning tree
37. Write program to calculate the area of polygons namely, Square, Rectangle, Triangle, Equilateral Triangle, Parallelogram, Trapezoid and circle. (Use function overloading)
Area of the polygons is given below.
Square A = side * side, where side is in integer variable
Rectangle = length * breadth, where length and breadth are integers
Circle = pi * radius * radius, where radius is a float variable
Triangle = 0.5 * breadth * height, where breadth and height are integer and float variables
Equilateral Triangle = 0.5 * breadth * height, where breadth and height are float and integer variables
Trapezoid = base1 * base2 * height, base1, base2 and height are integer variables
o Write main() program to demonstrate the function overloading
o Create a text file sample.txt. Write ten sentences into sample.txt, read and display them by opening it in read mode.
38. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix creation
• Kruskal’s Algorithm to construct minimum spanning tree
39. Create a class person with the data members *name, address of type character array. Create a class employee derived from class person with the data members basic pay, allowances, pf, gross and netpay of type integer. Create a class student derived from class person with the data members course, grade. Create a class parttime_student derived from student and employee with the data members stipend and total_income of type integer.
• Model this relationship using inheritance. Write a program to demonstrate the type of inheritance
• Allocate memory for the data member ‘name’ using constructor
• Deallocate the memory for ‘name’ using destructor
• Write suitable exceptions for the given scenario
40. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix creation
• Prim’s Algorithm to construct minimum spanning tree
Anna University , Chennai
Department of Computer Science Engineering
(Common to Information Technology)
CS6311 / IT6311 Programming and Data Structure Lab II
Important University Questions
Third Semester
2013 Regulation
CS6311: PROGRAMMING AND DATA STRUCTURES LABORATORY – II
1. Create a class Student with regno, name, CS1201, CS1202, CS1203 as data members. Include a member function to find the total and publish the result. Get minimum of five students' details and display the result in the form of list. Extend the Student into two different categories such as B.E and MCA Category B.E degree students have dept_name (CSE, ECE, EEE), dept_head, dept_location, core_subjects which is an array, subject_marks is an array containing the marks of the core subjects out of 100. Category MCA degree students have dept_name, dept_head, dept_location, core_subjects which is an array (whose size can be determined at the run time), subject_marks is an array containing the marks of the core subjects out of 100. Internal marks calculation is different for different categories of students. Internal marks (out of 100) for B.E students can be calculated as 50% of test1 + 50% of test2 (Considering two best tests out of three) Internal marks (out of 100) for MCA students can be calculated as 40% of test1 + 30% of test2 + 30% of test3 (Considering all the
three tests)
• Read and display the details of the Student with the operator overloading (<<, >>)
• Implement Calculate() in two different categories of the students and invoke them. (Use Virtual Function)
• Write the details of at least one category of the students in a binary file and show the details by reading from the file.
2. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
3. Develop a payroll application to compute the salary for the employees in an organization. Class Employee has general information namely employee_id, employee name, department_name, address, mobile number and email‐id. There are two types of employees such as training professionals and regular employees. The Definition of Pay_calculate() will be different for different types of employees. Include suitable menu for navigating the application. Training professionals has total teaching experience, qualification, no_of_sessions_handled. Salary = no_of_sessions_handled*one_day_salary (Both can be randomized values) Regular employees has department they belong to, basic_pay, designation Gross Pay = basic_pay+HRA+DA Net Pay = Gross Pay – PF HRA = 9% of Basic Pay, DA = 90% of Basic Pay, PF = 20% of Basic Pay
SNo Designation Basic_Pay
1 Manager 30000
2 Technical Lead 25000
3 Senior Software Engineer 20000
4 Software Engineer 15000
• Get and display details of different types of employees using operator overloading(<< , >>)
• Write suitable exceptions for the given scenario .
• Write a friend function LiseDeptWise() to list all employees for a given department_name.
4. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Prim’s Algorithm to construct minimum spanning tree.
5. Develop a banking application to computerize the operations in the bank. Account holder has general information that they require to provide are account_id, acct_holder_name, address, mobile number and email‐id. There are two types of account holders such as savings account & current account. Interest calculation definition will be different for different types of account holders. Include suitable menu for navigating the application.
o Savings account holder has purpose_of_account & balance
o Current savings account holder has type_of_business & balance
o Interest calculation will be done on the current balance.
o Interest calculation for savings account
o Interest = balance*8% of balance
o Interest calculation for current account
o Interest = balance*12% of balance
• Get and display details of different categories of account holders using operator overloading(<< ,>>)
• Write suitable exceptions for the given scenario .
• Implement the interest_calc method in two different types of account holders and invoke them. (Virtual Function)
6. Create a class BST with the data members node which is of type structure. This structure consists of the members element of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
Insert() – To insert an element into the binary search tree
Search() – To search for a given element in the tree
Inorder() – To perform inorder traversal for tree
FindMin() – To find the minimum element in the tree
7.Create class matrix with the data members 2D array, row and column of type integer. Overload the following operators and write the operator functions necessarily as member or friend of the class matrix.
>>(extraction operator) – to read the values for the data members
<< (insertion operator) – to display the values of the data members
+ (addition operator) ‐‐ to add two matrices
‐(unary minus) – to negate the values of a matrix
++(pre and post increment operator) – to increment the values of the data members of a matrix
Write the main() program to demonstrate the matrix object for unary and binary operator overloading.
8. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Prim’s Algorithm to construct minimum spanning tree.
9. Design a class Array as a template class with a single dimensional array and size of the array as data members. Template class need to work for different types of input (integer, float, char, char array, string, student, employee). Include the following member functions
‐ getArray() and printArray() to read and print the elements of the array
‐ sort()the array elements using bubble sort algorithm.
‐ To enable sorting employee or student objects based on a data member.
10. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the member functions to implement
• Adjacency matrix
• Dijkstra’s algorithm to solve the single source shortest path problem.
11. Create a class student with the data members roll number, name, marks array to hold marks for 5 subjects, total and a Boolean variable pass. Keep the following member functions in the class.
Void Read() – To read the data members
Void Print() – To print the data members
Void Result() – Computes the total and pass. Pass variable will be “true” if all the marks are >=50, otherwise, it is “false”.
Write a function template to sort the input values of type integer, float, char array, string and Student objects. Student objects need to be sorted based on their total.
• To sort integer, float and string values.
• To sort strings made up of character array.
• To sort student object based on the total.
12. A stack is a linear list of elements for which all insertions and deletions (usually accesses) are made at only one end of the list. Create a class with the data members integer array and the size. Write the following member functions and write menu driven () program to use those functions.
• Push (int X): pushes an element X on to the top of the stack – This function uses the IsFull() member function while pushing the data.
• int Pop(): pops the last pushed element. This function uses the IsEmpty() member function while popping the data from the stack .
• void Display(): to display the elements in the stack.
Write a program to find whether the given string is palindrome or not. (Use stack class).
13.Create a class Complex with the data members real and imaginary of integer type. Read two complex numbers and store them in a file. Write the following member functions.
• Read and print the complex numbers using stream operators. (<< , >>).
• Operator + () to perform complex number addition.
• Open the file, read complex numbers using input file stream and perform complex number addition.
• Store the resultant complex number in another file. (Use binary file stream).
14. Create a class BST with the data members node which is of type structure. This structure consists of the members of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
• Insert() – To insert an element into the binary search tree
• Preorder() – To perform preorder traversal for tree
• FindMax() – To find the maximum element in the tree
15. Create a class student with the data members roll number, name, marks array to hold the three UT marks for the subject PDS‐II, attendance (out of 5) and internal marks. Keep the following member functions in the class.
• To read and display the data members of student class.
• Compute_Internal() – Computes the internal marks.
• Create a binary file student.dat and insert 10 student objects in it.
• Find() – To find the student record given the position of it.
16. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
17. A Queue is a linear list of elements where an element will be inserted at the back end and deleted at the front end. Create a class queue with the data members integer array, front and rear. Include the following member functions in the class queue and write a menu driven (1. Insert, 2. Delete, 3. Display, 4. Exit) program to use the class queue.
Write suitable exceptions for the given scenario.
• bool IsEmpty(): return whether the queue is empty or not
• bool IsFull(): return whether the queue is full or not.
• Insert (int X): inserts an element X into the back end of the queue – This function uses the IsFull() member function while inserting the data.
• int Delete(): removes the element from the front end. This function uses the IsEmpty() member function while deleting the data from the queue.
• void Display(): to display the elements in the queue.
WWW.VIDYARTHIPLUS.COM
18. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• BFS() to perform breadth first search on the graph (use queue class).
19. Create a class person with a data member ‘namelist’ whose type is a double pointer. Memory space for this double pointer is allocated in the constructor of the class. Write a destructor to de‐allocate the memory of the character array. Include the following member functions:
• Read(), Disp() to read and display the data member ‘namelist’
• Create suitable constructor and destructor for the class person.
• Copy constructor to copy data members from one object to the other.
20. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
2 1. Consider an example of declaring the examination result. Design three classes: Student, Exam and Result.
The student class has data members such as roll number, name and address. Create the class Exam by inheriting the Student class. The Exam class adds data members to representing the marks scored in six subjects. Derive the Result class from the Exam class and it has its own data member ‘result’ which is of type bool. Include getResult() in Result class to set the corresponding value (true or false) based on the marks of the students given in Exam class.
Write an interactive program to model this relationship
Write a friend class to maintain the collection of result objects and include a member function to list the student details such as roll number, name, address, marks for six subjects based upon the result.
22. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Kruskal’s Algorithm to construct minimum spanning tree
23. Create a class called Circle with radius as data member and getCircle() and calcArea() as member functions to read the radius and calculate area of the circle.
Create a class called Cone which is derived from the Circle class. Utilize the data members and the member functions of the base class by the derived class to find the volume ((1/3)*3.14*r*r*h) of a cone. Create another class called Cylinder which is derived from the Circle class.
Utilize the data members and the member functions of the base class by the derived class to find the volume (3.14*r*r*h) of a cylinder.
• Get and retrieve the data members of cone and cylinder using operator overloading
• Use virtual function to find volume of the cone and cylinder and invoke them
24. Create a class BST with the data members node which is of type structure. This structure consists of the members element of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
• Insert() – To insert an element into the binary search tree
• Delete() – To delete a given element from the tree
• Preorder() – To perform preorder traversal for tree
25. Create a class matrix with the data members **m, row and column of type integer. Write the following member functions
• Overload stream operators (<<, >>) to read and display the matrix
• Overload binary minus (‐) operator to subtract one matrix from the other
• Overload unary minus (‐) operator to subtract the values of the elements of a given matrix
• Allocate memory for the data member ‘m’ using constructor
• Deallocate the memory for ‘m’ using destructor
26. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix
• DFS() to perform depth first search on the graph
27.Write a program to create a list container to maintain a set of integer elements and employee objects where an employee object consists of the data members name and empno. Implement the following
• Create a list of integer elements into the list container
• Insert into a list with the new element in the given required position
• Create a list of employee objects into the list container
• Insert into a list with a new employee object in the given required position
• Display the list the employee objects from the List container
28. Create a class BST with the data members node which is of type structure. This structure consists of the members of type integer, left and right which are of type pointer to the structure node. The other data member for the class is root which is a pointer to the node structure. Write the following member functions
• Insert() – To insert an element into the binary search tree
• Delete() – To delete a given element from the tree
• Postorder() – To perform postorder traversal for tree (
29. Create a class Time to display a time value with the data members of hours, minutes and seconds. Include the following member functions to get and display the time separated by: (HH:MM:SS). Assume the time is represented in 12 hours.
If the input value exceeds the hour, minute and second then your function should report the exception as invalid hour/minute/second.
Write an operator function binary minus (‐) to find which time is later. For example invoking T1‐T2 displays T1 is later or T2 is later
30. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the member functions to implement
• Adjacency matrix creation
• Kruskal’s Algorithm to construct minimum spanning tree
3 1. Create a class Student with the data members rollno, *name, mark array containing marks for maths and science subjects and cutoff mark.
Include member function calculate_cutoff() to find cutoff where cut off mark is calculated as ((maths+science)/200)*80.
Create another class Sports with the data members name, level, sports_mark. Level data member
represents the national or international level player. Include member function calculate_sportsmark() to assign sports_mark to be 10 if national player, otherwise 20.
Create another class Sports_Student derived from both the student and the sports with data member
total_cutoff and calculate total_cutoff() to add the cutoff and the sports_mark.
• Write suitable exceptions for the given scenario
• Allocate memory for the data member ‘m’ using constructor
• Deallocate the memory for ‘m’ using destructor
32. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer. Write the following member functions
• Create_Graph() to represent the graph using Adjacency matrix.
• DFS() to perform depth first search on the graph.
33. Write a program to create a map container to maintain a set of key, value pairs, where key is integer element and student object and value is the GATE score (out of 100). Student object has the data members rollno and name. Display the elements of the map container.
• Create a map container with 10 key,value pairs where key is the integer element and value is the GATE score
• Display the integer key, value pairs from the Map container
• Create a map container with 10 key, value pairs where key is the student object and the value is the GATE score
• Display the student key, value pairs from the Map container
34. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix
• Floyd‐Warshall algorithm to find the shortest path between every pair of vertices in the graph
35. Create a class employee with the data member empno. Create a class gross_salary which is derived from employee with the data members basic_pay, DA (92% of basic_pay), HRA (22% of basic_pay)of type float and the member function to compute gross_pay (i.e basic_pay + DA + HRA). Another class deduction that is derived from employee has the data members PF, medi_claim and the member function to compute deducted_amount (i.e PF + medi_claim). A class net_salary that is derived from both gross_salary and deduction has the data member net_pay and the member function to compute net_pay (i.e gross_pay ‐ deducted_amount).
• Model this hierarchy using inheritance
• Read and display the data members for the object result (use operator (<<, >>) overloading)
• Write compute_total() to find the total marks by adding part1, part2 and sports_mark
• Write suitable exceptions for the given scenario
36. Create a class Graph with the data member 2D array and the number of nodes of type integer. Write the member functions to implement
• Adjacency matrix creation
• Kruskal’s Algorithm to construct minimum spanning tree
37. Write program to calculate the area of polygons namely, Square, Rectangle, Triangle, Equilateral Triangle, Parallelogram, Trapezoid and circle. (Use function overloading)
Area of the polygons is given below.
Square A = side * side, where side is in integer variable
Rectangle = length * breadth, where length and breadth are integers
Circle = pi * radius * radius, where radius is a float variable
Triangle = 0.5 * breadth * height, where breadth and height are integer and float variables
Equilateral Triangle = 0.5 * breadth * height, where breadth and height are float and integer variables
Trapezoid = base1 * base2 * height, base1, base2 and height are integer variables
o Write main() program to demonstrate the function overloading
o Create a text file sample.txt. Write ten sentences into sample.txt, read and display them by opening it in read mode.
38. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix creation
• Kruskal’s Algorithm to construct minimum spanning tree
39. Create a class person with the data members *name, address of type character array. Create a class employee derived from class person with the data members basic pay, allowances, pf, gross and netpay of type integer. Create a class student derived from class person with the data members course, grade. Create a class parttime_student derived from student and employee with the data members stipend and total_income of type integer.
• Model this relationship using inheritance. Write a program to demonstrate the type of inheritance
• Allocate memory for the data member ‘name’ using constructor
• Deallocate the memory for ‘name’ using destructor
• Write suitable exceptions for the given scenario
40. Create a class Graph with the data members adjacency matrix and the number of nodes of type integer.
Write the member functions to implement
• Adjacency matrix creation
• Prim’s Algorithm to construct minimum spanning tree
0 comments:
Pen down your valuable important comments below