![]() |
CS201 ASSIGNMENT NO. 2 FALL 2022 |
CS201 ASSIGNMENT NO. 2 FALL 2022 || 100% RIGHT SOLUTION || INTRODUCTION TO PROGRAMMING || BY VuTech
Visit Website For More Solutions
www.vutechofficial.blogspot.com
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
kamranhameedvu@gmail.com
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
o Assignment is submitted after due date.
o Submitted assignment does not open or file is corrupt.
o Assignment is copied (From internet/students).
Software allowed to develop Assignment
- Dev C++
Objectives:
To enable students to understand and practice the concepts of:
- Classes and its structure.
- Data Members and Member functions of a class.
- Constructor of a class.
- Friend function
- Operator overloading
Assignment Submission Instructions
For any query related to assignment, please contact cs201@vu.edu.pk.
Problem Statement
Following property is true for any two matrices of same order:
(A + B) T = AT + BT
Here...
- A & B are two matrices of same order.
- T stands for transpose of a matrix.
- AT and BT are transpose of matrices A and B respectively.
- Left side of the above equation means:
- Two matrices A and B are added first and then
- The transpose of the resultant is computed.
- Right side means:
- Transpose of both matrices A and B are computed first and then
- Their resultants (transposes) are added.
You have to write a program in C++ to find ONLY the Left Hand Side of this property means (A + B) T.
For this purpose:
Write a class MatrixProperty:
This class should have:
Ø A two dimensional array named matrix of integers of dimension 2 x 2.
Ø A setter method setMatrix () which should assign the passed array to the array matrix.
Ø It should have two constructors:
· A default constructor which should initialize the array matrix to zero.
· A parametrized constructor which should take an array as a parameter and initialize the array matrix with this passed array.
v Here you should call the setMatrix() to do the task.
Ø An overloaded + operator which should take references to two objects of MatrixProperty and
· Add the two matrices(arrays) of these two objects.
· Return a reference to the resultant matrix.
Ø A friend function Transpose() which should take one argument:
· a reference to an object of MatrixProperty
· Find transpose of this passed array matrix and
· Return a reference to this resultant matrix.
Ø A function display() which could either take a reference to an object of MatrixProperty or use this pointer
· To display the passed matrix.
In the main() function, you should:
Ø Make TWO instances of this class MatrixProperty using the following matrices(arrays).
Ø Add the above TWO created matrices using the overloaded + operator.
- Call Transpose() function to find transpose of resultant(sum) matrix (done in the above step).
Ø Call Display() function to:
v display both matrices A and B.
v display the sum(matrix).
v display the transpose(matrix).
Note: You may use pointers to pass the array arguments to all functions and do the pointer arithmetic.
(Hint: Transpose of a matrix can be obtained by changing its rows into columns or columns into rows.)
(Hint: Two matrices can be added by adding their corresponding elements.)
For consistency of the assignment, please only use the above given matrices(arrays).
Note: Marks will be deducted if the given arrays are not used.
Sample Screenshot of Output:
Good Luck!
Lectures Covered: This assignment covers Lecture # 23-31.
Deadline: The deadline to submit your assignment solution is 24th January 2023. Your assignment must be submitted within the due date through VU-LMS. No assignment will be accepted through email after the due date.
Visit Website For More Solutions
www.vutechofficial.blogspot.com
KINDLY, DON’T COPY PASTE
SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
kamranhameedvu@gmail.com