Write a C++ program to 1. Initialize Matrices 2. Print Matrices 3. Multiply Matrices 4. Transpose of 2nd Matrix 5. Move Row and Column of 2nd Matrix 6. Quit




Write a program that shows a menu such as figure 2.1 and does the following described tasks for entered number between 1 and 6.

The instruction menu:
1. Initialize Matrices
2. Print Matrices
3. Multiply Matrices
4. Transpose of 2nd Matrix
5. Move Row and Column of 2nd Matrix
6. Quit
Please enter your requested instruction (1..6)?
Note that to do the specific task related to each menu user should press relevant number. (e.g. ‘2’ for print task or ‘4’ for transpose operation). The description of tasks is as follows:
1. Initialize:
In this step, your program should get dimensions for two matrices from input and initials these matrices randomly based on the entered dimensions. Note that your program should initialize matrices with different numbers in each time of execution. The first matrix should be square matrix. A square matrix is a matrix with the same number of rows and columns. Note that user can re-initialize matrices (and of course dimensions) by using the first command during the execution
Please enter the number of rows and columns for the first square matrix? 3
Please enter the number of rows for the second matrix? 4
Please enter the number of columns for the second matrix? 6
2. Print:
In this step, your program should print the content of two matrices in the screen as showed in the figure 2.3. The “Print” operation could be requested after each step to see the changes which have been made during the execution of different instructions. It means that you do not need to show the results of each operation in the screen, user has to request instruction number ‘2’ to see the actual content of matrices.
Content of the first Matrix (3*3):
1 3 5
9 7 8
98 6 51
Content of the second Matrix (4*6):
34 73 83 23 98 20
81 92 68 28 34 76
-65 78 -12 67 1 123
89 -61 67 43 17 84
3. Multiplication:
In this step, your program should multiplies two matrices A and B (C=A*B).
4. Transpose:
In this step, your program should calculate transpose of the second matrix. Wikipedia
defined transpose of a matrix as follows:
“In linear algebra, the transpose of a matrix A is another matrix AT created by any one of the
following equivalent actions:
 reflect A over its main diagonal (which runs top-left to bottom-right) to obtain AT
 write the rows of A as the columns of AT
 write the columns of A as the rows of AT
 visually rotate A 90 degrees clockwise, and mirror the image in a vertical line to
obtain AT
Formally, the (i,j) element of AT is the (j,i) element of A. [AT]ij = [A]ji
If A is an m × n matrix then AT is an n × m matrix.”
5. Move row and column:
In this step, your program should get two numbers (m, n) and first moves
the row number m of the second matrix to the end of the matrix and then moves the column
number n of the matrix to the end of the matrix
6. Quit:
In this step, the execution should be ended. Note that your program shouldn’t be finished in
other steps. It means that user can request multiple executions of different steps before requesting the “Quit” operation.
Points:
User needs to initiate matrices at least once by requesting step ‘1’ at the beginning of an execution.
Therefore you should prevent the user for requesting other steps before step ‘1’ just once at the
beginning of an execution.
Solution-

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com