Question: In C++ please, and i need EXACT results! Warning: do not use vectors in this exercise. Write a program that takes the input of a
In C++ please, and i need EXACT results!
Warning: do not use vectors in this exercise.
Write a program that takes the input of a 3x3 matrix (with 9 integers as its entries) from the user. The following shows an example input:
1 9 0 3 6 4 8 2 1
The first three integers are then assigned to the three entries of the first row of the 3x3 matrix, and the second set of three integers will be assigned to the second row of the matrix, etc.
(1) Complete the above reading and assignment of individual entries of the 2D matrix, then output the matrix. Given the above user input, the output matrix will be as follows
1 9 0 3 6 4 8 2 1
(2) Compute and output the sum of the diagonal entries (i.e., [0][0], [1][1], and [2][2]). For example, given the above nine integers as the input, the program will output
1 9 0 3 6 4 8 2 1 8
(3) Compute and output the transpose of the input matrix. For example, given the above input, the program will output
1 9 0 3 6 4 8 2 1 8 1 3 8 9 6 2 0 4 1
Hint: The logic for the transpose of a square matrix is transpose_matrix[i][j] = original_matrix[j][i]. Use a nested loop to go over the individual elements to get the transpose matrix.
Any attempt to hard code answers will result in a 0 for the exercise.

Warning: do not use vectors in this exercise. Write a program that takes the input of a 3x3 matrix (with 9 integers as its entries) from the user. The following shows an example input: 1 9 0 3 6 4 8 2 1 The first three integers are then assigned to the three entries of the first row of the 3x3 matrix, and the second set of three integers will be assigned to the second row of the matrix, etc. (1) Complete the above reading and assignment of individual entries of the 2D matrix, then output the matrix. Given the above user input, the output matrix will be as follows 1 9 0 3 6 4 8 2 1 (2) Compute and output the sum of the diagonal entries (i.e., [0][0], [1][1], and [2][2]). For example, given the above nine integers as the input, the program will output 1 9 0 3 64 8 2 1 8 (3) Compute and output the transpose of the input matrix. For example, given the above input, the program will output 1 90 36 4 8 2 1 8 1 3 8 9 6 2 0 4 1 Hint: The logic for the transpose of a square matrix is transpose_matrix[i][j] = original_matrix[j][i]. Use a nested loop to go over the individual elements to get the transpose matrix. Any attempt to hard code answers will result in a 0 for the exercise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
