Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

ANNA UNIVERSITY : CHENNAI 600 025

B.E.,/B.Tech., Degree Examinations, Oct - 2014


Regulations 2013
Third Semester
(B.Tech., Information Technology)

IT6311 Programming and Data Structures II Lab


Time: 3 Hours Maximum Marks: 100

1. (a) Write a Class named as bank. Include the member variables as Depositor name, Account
number, Balance amount and member functions to assign initial values, deposit an
amount and display name and balance amount using constructor. Check the balance if it
is zero then destroys the account details by using Destructor. 50

(b) Write a Class Complex with real and imag as data member. Use binary operator + to
read and print the member values. Write a main program to express the Complex class.
50

2. (a) Write a class code. Take a reference to an object of the same class as itself as an argument.
Using Copy Constructor copy the content of one object to another object and display the
arguments of both objects. 50

(b) Write a function generated from template function with integer variables and float
variables. Assign five different unordered values to the variables. Using Bubble sort, find
the ordered values of variables. 50

3. (a) Write two classes named as readinput and summation. Read n number of values in the
first class. Find the sum of n values in the second class by using friend function. 50

(b) Write a Class named as vector using class template receive int type vector and float type
vector and find the scalar product for both the types by using Binary Operator
Overloading and display the result of the product. 50
4. (a) Create the relevant member functions to calculate the area of circle, rectangle and triangle
using Function Overloading. Write the main program to receive the input values and to
display the corresponding output value. 50

(b) Write the member function size() to give the size of the vector. Create an int type vector
v, the program assigns five values into the vector using the member function push_back()
takes a value as its argument and adds it to the back end of the vector. Perform insertion
and deletion operations to the vector by using Standard Template Library. 50

5. (a) Write a C++ program to read the data from the keyboard and write it to the file. After the
writing is completed, the file is closed. The program again opens the same file, reads the
information and displays the same on the screen. 50

(b) Write a C++ program to covert the infix expression


a+b*c/d
to postfix expression using the application of stack. 50

6. (a) Write a C++ program, using the STOCK.TXT file with five items code, name and cost.
Perform the following operations on the file:
(i) Adds a new item to the file.
(ii) Modifies the details of an item.
(iii) Displays the contents of the file. 50

(b) Write a C++ program to create an array with n number of elements and arrange the array
elements in a sorted order. Find the specific key element of index value by using the
application of Binary Search Tree. 50
7. (a) Write a Exception handling program using mechanisms of try, throw and catch to detect
the error and catch the arithmetic exception of divide-by-zero problem. Check the value
of the division is it not zero then display the output else display the error message in the
main program. 50

(b) Write a program for Queue data structure maintains two pointers, front and rear. The
front points the first item of queue and rear points to last item. Perform the following
operations in the program:

enQueue() This operation adds a new node in rear point.

deQueue() This operation removes the element from front. 50

8. (a) Write three different classes named as student, test, and total. Class student stores the
roll_number, Class test stores the marks obtained from three subjects and class result
contains the total marks obtained from the test. The class result can inherit the details of
the marks obtained from the test and the roll_number of students through multilevel
inheritance. 50

(b) Write a C++ program to create an array with n number of elements and arrange the array
elements in a sorted order in descending. Find the specific key element index value by
using Binary Search Tree and remove the element from the array. 50

9. (a) Write a class named as media that stores the title and price of a publication. Create two
derived classes, one for storing the number of pages in a book named as book and another
for storing the playing time of a tape named as tape. Using virtual function display() the
details of book and tape. 50

(b) Create a class Student with members rollno, name, and deptname. Create a friend
function deptwise to list all students for a given dept. 50
10.(a) Create a class Time with hour, minute and second as data members. Include the methods
gettime(), showtime() to read and display two time values respectively. Write one more
method binary operator - (minus) to find the difference between two values. 50

(b) Perform traversal of a connected, undirected graph visits all the vertices in that graph.
The set of edges which are traversed during a traversal forms minimum spanning tree for
the given example graph. 50

11.(a) Create a class Distance with meter as data members. Include a constructor and a member
function showDistance( ) to set and print the member values respectively. Write the main
method to demonstrate the Distance for two different data member values.
50

(b) With reference of binary tree:

14
/ \
2 11
/ \ / \
1 3 10 30
/ \
7 40

Write the program to find the order of the nodes :


(i) An in-order traversal
(ii) A pre-order traversal
(iii) A post-order traversal 50
12.(a) Create a class Stack with functions push() and pop().Check whether the Stack is full or
empty and accordingly raise exceptions as Stack Overflow or Stack Underflow.
50

(b) Write a C++ program to create a hierarchy of class to find the area of different objects
such as rectangle, square and circle. 50

13.(a) Write a C++ program to find the cube of a given numbers of different data types using
single function as a template type and display the result with different data types. 50

(b) Write a C++ program to implement stack operations using exception handling mechanism.
50

14. (a) Write a C++ program to concatenate two strings using Function Overloading. 50

(b) Write a C++ program to implement queue operations using exception handling
mechanism. 50

15. (a) Write a C++ program with a class named as area to find the area of the room and
inherit this property into another class named as volume to find out the volume of the
same room and display both the results. 50

(b) Create a class Queue with functions insert() and delete().Check whether the Queue is full
or empty and accordingly raise exceptions as Queue is full or Queue is empty.
50
16. (a) Write three different classes named as employee, salary and payroll. Class employee
stores the empno, empname and design . Class salary stores basic, da and pf. Inherit
minimum of five employees and obtain the payroll using multiple inheritance. 50

(b) Create a class called Point with the data member of x and y coordinates. Write a member
function to get and display the points. Overload the + and operator to perform addition
and subtraction of two points. 50

17. (a) Create a class Vector with size as static data member and an integer array as one
dimensional pointer data type. Use appropriate constructor and destructor to allocate and
de-allocate memory for the vector data member. 50

(b) Write a C++ program to find the shortest path by using Dijkstras algorithm. 50

18. (a) Create a class Code having a private data member id. Create an object and assign the
value for the data member using one argument constructor. Create multiple objects and
assign the first objects value to all remaining objects by using Copy constructor. 50

(b) Write a C++ program to find Preorder, and Postorder Traversals by giving suitable
Inorder expression. 50
19. (a) Create a class Matrix with rows, cols and a two dimensional arrays data members.
Overload the assignment operator to assign one matrix object to another matrix object.
50

(b) Write a C++ program to add and subtract the given two numbers in two separate classes
and, multiply and divide the added and subtracted values in the third class.
50

20. (a) Create a class matrix with rows and cols as data members. Get rows and cols values for
getmatrix() function (2x2 or 3x3). Perform matrix addition by using function template and
display the result of the matrix.
50
(b) Create a class Student with data members name, rollno and dept. Open a file to store the
student object. Open the same file in ios::in mode to read and display the content.
50

You might also like