Question: Consider the sample program provided below. In the main function, complete the missing code (in c source code) in PART 1 to PART 5. I)
Consider the sample program provided below. In the main function, complete the missing code (in c source code) in PART 1 to PART 5.
I) Initialize matrix A and B with numbers from 1 to PxQ and QxR, as shown below. Ex. A= 0 1 2 3 4 5 6 7 8 9 10 11 B= 1 2 3 4 5 6 7 8 II) Compute the matrix C by multiplying the matricies A and B. A x B = C. III) Compute the sum of the entires in C. VI) Compute the sum of the entires on the border (edge) of matrix B. V) Switch the first and the last row in matrix A.
#define P 3 // Matrix A is (P x Q) #define Q 4 // Matrix B is (Q x R) #define R 2 // Matrix C is (P x R) int A[P][Q] = {0}; int B[Q][R] = {0}; int C[P][R] = {0}; void hw4_5(){
// PART 1: Initialize A and B ENTER CODE HERE // PART 2: matrix multiplication ENTER CODE HERE // PART 3: Compute the sum of the entries in C int sum0 = 0;
ENTER CODE HERE printf("The sum of entires in C: %d ",sum0); // PART 4: Compute the sum of entries on the border of matrix B int sum1 = 0; ENTER CODE HERE printf("The sum of border entires in B: %d ",sum1); // PART 5: Switch the first and last row in matrix A ENTER CODE HERE // print matrix A printf(" "); for(int i = 0; i < P; i++){ for(int j = 0; j < Q;j++){ printf("%d ",A[i][j]); } printf(" "); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
