# Data Structure Questions and Answers-Matrix

## Data Structure Questions and Answers-Matrix

 Question 1
What is the order of a matrix?
 A number of rows X number of columns B number of columns X number of rows C number of rows X number of rows D number of columns X number of columns
Question 1 Explanation:
By definition, the order of a matrix is number of rows X number of columns, generally denoted by mXn(not compulsory).

 Question 2
Which of the following property does not hold for matrix multiplication?
 A Associative B Distributive C Commutative D None of the mentioned
Question 2 Explanation:
In matrix multiplication, AB != BA

 Question 3
How do you allocate a matrix using a single pointer in C?(r and c are the number of rows and columns respectively)
 A int *arr = malloc(r * c * sizeof(int)); B int *arr = (int *)malloc(r * c * sizeof(int)); C int *arr = (int *)malloc(r + c * sizeof(int)); D int *arr = (int *)malloc(r * c * sizeof(arr));
Question 3 Explanation:
Total number of elements in the matrix will be r*c

 Question 4
Select the code snippet which performs matrix multiplication.(a and b are the two given matrices, resultant marix is c)
 A for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = B for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k =  D None of the mentioned
Question 4 Explanation:
The corresponding elements from the row and column are multiplied and a cumulative sum is formed.

 Question 5
What does the following piece of code do?

for(int i = 0; i < row; i++) { for(int j = 0; j < column; j++) { if(i == j) sum = sum + (array[i][j]); } } System.out.println(sum);
 A Normal of a matrix B Trace of a matrix C Square of a matrix D Transpose of a matrix