University Centre for Computer Science & Information Technology

University of Rajasthan, Jaipur

MCA II Semester 2018

MCA 811: Programming in C++ Lab
Assigned: 20 March 2018                        2nd assignment                                Due: 17 April 2018


  1. Write a c++ program to create array of pointers to objects (students class having rollno, name as members of the class) then display the students details.

  1. Define a class counter that contain count (int). Increment counter variable using overloading unary operator++.

  1. Write a c++ program using operator overloading to add two strings.

  1. Write a c++ program to overloading of required operators for complex class to perform basic operations.

  1. Write a c++ program to count number of objects created and deleted.

  1. Write a c++ program to overload arithmetic operator + for manipulating objects of distance class, which having distance in feet and inches.

  1. Write a c++ program to copies the data members from one object to another for vector elements using (i) copy constructor (ii) assignment operator overloading.

  1. Using distance class create an overloaded * operator so that two distance can be multiplied together. Make it a friend function so that you can use such expressions as dist I = 7.5*dist2.

  1. Design three classes: Student, Exam and Result. The Student class has data members such as roll number, name, class etc. Create the class Exam by inheriting the Student class. The Exam class adds data members marks of six subjects. Derive the Result from the Exam class and it has its own data member total marks. Write a interactive program to model this relationship.

  1. Design four classes: Student, Exam, Sports and Result. The student class has data members such as roll number, name class etc. Create  the class Exam by inheriting the Student class. The Exam class adds data members marks of six subjects and also create the class Sports by inheriting the Student class. The Sports class adds data members sport weightage. Derive the Result from the Exam and Sports classes and it has its own data member performance. Write a interactive program to model this relationship such that members of student class are not inherited twice.

  1. Write a c++ program to design three independent classes: Student class with student’s details, internal and external classes with obtained marks and max marks of three subject and make a function to friend of the classes internal and external to access functionalities in the student class to prepare student marksheet.

  1. Design Shape as Base class and Points, Lines, Triangle, Rectangle, Square and Circle as hierarchical derived classes with appropriate data members and member functions to draw objects of the classes. Create an array of pointers containing addresses of objects of the above classes with virtual function Draw() and virtual destructors.

  1. Write a template based c++ program to demonstrate multiple swap functions for swap values of integers, float, double and characters and function overloading.

  1. Write a function template for finding the largest number in a given array. The array parameter must be of generic-data type.

        Your Name:                                                                         Please go on to the next page...

  1. Write template based binary search function using recursive algorithm.

  1. Write a program to I/O operation on complex numbers using overload screen stream operators << of ostram class and >> of istram class and friend functions.

  1. Write a c++ program of file creation ("text") enter string char by char and display.

  1. Create a file stock using class inventory having item-name, code, cost. Perform input and output operations using the stock file.

  1. Create a student class containing roll number, name, class and address of students. This class should have overloaded stream operator functions to save or retrieve objects of the student class in a file. Write an interactive c++ program to manipulate objects of the student class with a file.

  1. Write an interactive c++ program to computer square root of a number. The input value must be tested for validity, if it is negative, the user defined function mysqrt() should raise an exception.

  1. Write an interactive c++ program which divides two complex numbers. Overload divide (/) operator and handle eases such as division by zero using exception.

  1. Write a c++ program to create a stack class, which perform push and pop operation on the stack of array implementation. To check whether the stack is full or not in case of push operation and to check whether the stack is empty or not in case of pop operation.

  1. Write a c++ program to implement a recursive binary search.

  1. Write a c++ program to perform the following operations using queue structure:
  1. Create a queue.
  2. Add a new element
  3. Search an existing element in the queue
  4. Delete an existing element from the queue.

  1. Write a c++ program to implement the following operations using linked list of integers:
  1. Create a linked list.
  2. Insert an element at a given position.
  3. Find an element in the linked list.
  4. Delete a specified element from the list.

        End of 2nd assignment.

Note:– Students marked as All (1-13) in 1st assignment, can send their files for assignment 2 at google drive. I would like to send comments and discuss files send by students:

        Step 1: Login with your google account and open https://drive.google.com/drive/my-drive

        Step 2: Click on New and create a folder with your name following uccsit. (eg: for me it is sanjeev_uccsit)
                (You have to create a folder only for first time, after that you have to follow only step 4)

        Step 3: Share the folder with computerlab.physics@gmail.com

        Step 4: Upload your c++ files in the above folder.

For quick response, you can send me another email for comments at sanjeev@uniraj.ac.in (without attachments).