InterviewSolution
Saved Bookmarks
| 1. |
Write an algorithm to add corresponding elements of two matrices A[3 x 3] and B[3 x 3] |
|
Answer» /* Read the two matrices */ 1. for i=1 to 3 perform step 2 through 4 2. { for j=1 to 3 perform step 3 through 4 3. { Read A[i,j] 4. Read B[i,j] } } /* Calculate the sum of the two and store it in third matrix C */ 5. for i=1 to 3 perform step 6 through 8 { 6. for j=1 to 3 perform step 7 through 8 7. { C[i,j]=0 8. C[i,j]=A[i,j]+B[i,j] } } |
|