5.3 - Assignment 2 - Matrix
5.3 - Assignment 2 - Matrix
Assignment 2
Write a program that takes two matrices from user and performs following operations:
- Matrix Addition
- Transpose of a matrix
- Checks if a matrix is symmetric or not
- Interchange rows of a matrix
Important Notes:
- You cannot change the prototypes of the functions.
- You can use subscript operator to allocate and deallocate the memory.
- Your program should follow the exact sequence of Sample Run given below.
- Goto instruction is not allowed in your program.
- Submit only one running cpp file having all the functionality. DO NOT submit
compressed files. Submit your data file as well to avoid any file related issues during
evaluation.
- DO NOT take any input from user, we are taking input from file only.
- Violation of any of the above instructions may result in ZERO credit or marks deduction.
Matrix B =
2 5 8
5 6 9
8 9 10
Matrix C =
2 3 4
5 6 7
A+B=
3 7 11
9 11 15
15 17 19
A+C =
Addition not possible.
Transpose of A =
1 4 7
2 5 8
3 6 9
Transpose of C =
2 5
3 6
4 7
Matrix A is NOT Symmetric
Matrix B is Symmetric
Note: These are only sample inputs. Your assignment may be evaluated on any value supported
by data type.
InputFile.txt (Create a file InputFile.txt and paste following data in the file. Name of the file in
your code should be “InputFile.txt”, it will be evaluated accordingly.) Submit your data file in
assignment submission with your only one running cpp file.
//Format of data is given below
//Line1: Rows Cols
//Line2: <matrix[0][0]> <matrix[0][1]> <matrix[0][2]>...
//Line3: <matrix[1][0]> <matrix[1][1]> <matrix[1][2]>...
//Line4: Next Row and so on
//Matrix A
33
123
456
789
//Matrix B
33
258
569
8 9 10
//Matrix C
23
234
567
Input.txt
33
123
456
789
33
258
569
8 9 10
23
234
567