0% found this document useful (0 votes)
71 views

OOP-CS252 - Programming Test 1

The document provides instructions for 5 programming problems involving object-oriented concepts in C++. The problems involve creating classes for DATE, MATRIX, STRING, STACK, and OCTAL and implementing operations like addition, subtraction, concatenation by overloading operators. The programs are expected to be well-indented, compile without errors, and not be directly copied from other sources.

Uploaded by

Hemanth Yenni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

OOP-CS252 - Programming Test 1

The document provides instructions for 5 programming problems involving object-oriented concepts in C++. The problems involve creating classes for DATE, MATRIX, STRING, STACK, and OCTAL and implementing operations like addition, subtraction, concatenation by overloading operators. The programs are expected to be well-indented, compile without errors, and not be directly copied from other sources.

Uploaded by

Hemanth Yenni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

OOP-CS252 -Programming Test

1 Write a C++ program to create a class called DATE. Accept two valid dates in the
form of dd/mm/yyyy. Implement the following operations by overloading the
operator + & -. After every operation display the results by overloading the operator
<< .
i) no_of_days=d1-d2, where d1 and d2 are DATE objects, d1>=d2, no_of_days is an
integer.
ii) d2=d1+no_of_days, where d1 is DATE object and no_of_days is an integer
2 Create a class called MATRIX using two-dimensional array of integers. Implement
the following operations by overloading the operator == which checks the
compatibility of two matrices to be added and subtracted. Perform the addition and
subtraction by overloading the + and – operators respectively. Display the results by
overloading the operator <<.
If (m1== m2)
then m3 = m1+m2
and m4 = m1- m2
else display error.
3 Write a program in C++ to create a class called STRING and implement the
following operations. Display the results after every operation by overloading the
operator <<.
i. STRING s1 = “NIT”
ii. STRING s2 = “ GOA”
iii. STIRNG s3 = s1 + s2; (Use copy constructor)
4 Write a program in C++ to create a class called STACK using an array of integers
and to implement the following operations by overloading the operators + and - :
i. s1=s1 + element; where s1 is an object of the class STACK and element is an
integer to be pushed on to top of the stack.
ii. s1=s1-- ; where s1 is an object of the class STACK and -- operator pops off the top
element.
Handle the STACK Empty and STACK Full conditions. Also display the contents of
the stack after each operation, by overloading the operator <<.
5 Write a program in C++ to create a class called OCTAL, which has the
characteristics of an octal number. Implement the following operations by writing an
appropriate constructor and an overloaded operator +. i. OCTAL h = x ; where x is
an integer ii. int y = h + k ; where h is an OCTAL object and k is an integer. Display
the OCTAL result by overloading the operator <<. Also display the values of h and
y.
Instructions:
1. The programs should be readable and well indented.
2. The programs should compile on a standard C++
compiler.
3. If it is found that the program has been copied from any
source, there will be a penalty. No communication will
be made with respect to this with the students.
4. If any two students programs are found same, then both
will be awarded penalty.

You might also like