C - Assignment - BCS2A - BCS2B
C - Assignment - BCS2A - BCS2B
2) Write a program in C++ to find areas and perimeters of circle, triangle, rectangle and square by creating
objects using constructor
5) Write a program to find out the minimum among n numbers using STL.
6) Implement a stack where each stack object deals with a different array size as per user’s given size.
9) Create a class template Queue and implement insert and deletion operation on following data-types, (1) int
(2) float (3) char
10) Write down a program on C++ to define a class Matrix which uses a 2D array and two counters rlimit and
climit to hold the row size and column size of the matrix. Define member functions which performs
i. Matrix Addition
ii. Matrix Multiplication.
11) Create a class called time that has a separate integer member data for hours, minutes and seconds. One
method initializes it to fixed values. A member function should display it, in HH:MM:SS format. The final two
member functions should add and subtract two objects of time passed as arguments. A main() program should
create two initialized time objects. Then it should add the two initialized objects, storing the result in a third
time object. Finally it should display the value of the third object.
12) Write a program to print the names of students by creating a Student class. If no name is passed while
creating an object of Student class, then the name should be "Unknown", otherwise the name should be
equal to the String value passed while creating object of Student class
13) Suppose you have a Piggie Bank with an initial amount of $50 and you have to add some more amount to
it. Create a class 'AddAmount' with a data member named 'amount' with an initial value of $50. Now make
two constructors of this class as follows:
1 - without any parameter - no amount will be added to the Piggie Bank 2 - having a parameter which
is the amount that will be added to Piggie Bank Create object of the 'AddAmount' class and display
the final amount in Piggie Bank.
14) Create a function template that can perform some sorting operation on following data-types, (1) int
(2) float (3) char
15) An election is contested by 5 candidates. The candidates are numbered 1 to 5 and the voting is done by
marking the candidate number in the ballot paper. Create a class BallotBox to read the ballots and count the
votes cast for each candidate using an array variable count. In case a number read is outside the range 1 to 5
the ballot should be considered as “spoilt ballot” and the program should also count the number of spoilt
ballots.
16) Write a C++ program using array of objects that store player name, match played and run scored for
given number of players. Involve member functions to obtain playerwith maximum match played, maximum
run scored and maximum average.
17) Write a program in C++ to implement class ADD that will have 3 overloaded functions. 1 st one will add
two integer numbers. 2nd one will add two floating and one integer number. And 3rd one will take two
complex objects as parameter and will add two complex numbers.
18) Assume that object represents an employee report that contains the information about employee id, total
bonus, and total overtime in a particular year. Use four objects to represent four employees' reports. Write a
program that display report information. Use setpara() overloaded member functions to set report attributes
by passing/without passing the arguments and member function displayreport() to show the reports according
to parameter passed.
19) Create a class named 'Rectangle' with two data members- length and breadth and a method to claculate
the area which is 'length*breadth'. The class has three constructors which are :
1 - having no parameter - values of both length and breadth are assigned zero. 2 - having two
numbers as parameters - the two numbers are assigned as length and breadth respectively.
3 - having one number as parameter - both length and breadth are assigned that number.
Now, create objects of the 'Rectangle' class having none, one and two parameters and print their
areas.
20) Design classes called Polar and Rectangle for representing a point in the polar and rectangle systems.
Support data conversation functions to support such as:
Rectangle r1, r2; Polar p1, p2;
R1=p1; p2=r2;
21) Suppose in a hospital there are doctors of different departments and patients are treated . Each patient can
be treated by a single doctor. Write a program that a patient can choose a concerning doctor of a department.(
Use Friend Class).
22) Design classes called ANGLE and POLAR ,they are friend class .Write a program to convert angle to polar
where angle can access only getdata() of angle class.
23) Create two class DM & DB which store the value of distances. DM stores it in meter & centimeters. DB
stores it in feet & inches. Write a program that can read values for the class objects & add one object of DM
with another object of DB. Use a friend function to carry out the addition operation. The objects that store the
result may be of either type depending on the units in which the results are required. The display function
should act accordingly
24) Create a class String then implement the following operation i. Overload the + operator for string
concatenation. ii. Overload the – operator for subtract the
length of two string. iii. Overload the < operator for string comparison.
25) Implement the queue operation with overload unary+ for push operation & unary- for pop operation. Your
queue implementation must be menu based.
26) Create a class complex that contains two double data members. Overload +,-, and * arithmetic operators,
so that they can operate on the object of complex. Then find the expression a-b*c+d (where a, b, c, and d are
complex objects).
27) Consider problem no:24 thenWrite a program in C++ to check whether two distance objects(one
is object of DM another is object of DB) are equal by overloading “==” and “>” operator.
29) Write a program to manipulate linked list supporting node operation as follow:
a.node=node+6; //create a new node with new information 6
b.node=node-2; //delete a node having information 2
30) Write a program to implement a base class CONSUMER and a derive class TRANSACTION. Both have
overridden member functions getdata() and display(). The functions in base class have been declared
virtual. And again make the base class member functions pure virtual.
31) write an interactive program to create a graphic class hierarchy. Create an abstract base class called
Figure and two derived classes Close and open. Decrale two more classes called Polygon and Ellipse using
close class. Create derived class Line from open class.Define three objects(triangle rectangle and oval)of
class polygon All classes must have appropriate member functions including constructor and destructor. .
32) Create the function called swaps() that interchange the values of the two argument sent to it(you will
probably want to pass the arguments by reference). Make the function into template, so it can be used with
all data types (such as int, float, char, string). Write a main () program to exercise the function with several
types.
33) Writ an interactive program which divides two numbers. Here inputs are actually passed by command
line arguments. Enhance your design by using exception handling (possible cause of exception-number of
arguments must be 2, divide by 0, both arguments must be a number).
34) This is the database of the employees of an Educational Institute. Specify all the
classes & define functions to create database & retrieve individual information when required.
35) Create a class String , capable to throw an exception named “StringLengthTooLongException ” if any
one of the following condition is mate i. Input String length is greater than 32 ii. After concatenation
between two strings resultant string is greater than 32.