Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the code fragment below: Code Listing 2.1 int row[]={0,0,0}; int col[]=

ID: 3653622 • Letter: C

Question

Consider the code fragment below: Code Listing 2.1 int row[]={0,0,0}; int col[]={0,0,0}; int diag[]={0,0}; int mask[]= { 1, 0, 3, 0, 2, 2, 3, 2, -1}; int i,j; const int DIM = 3; for (i=0; i < DIM; i++) { for(j=0; j < DIM; j++) { row[i] = row[i] + mask[i*DIM + j]; col[j] = col[j] + mask[i*DIM + j]; if (i == j) diag[0] = diag[0] + mask[i*DIM + j]; if (i + j == DIM - 1) diag[1] = diag[1] + mask[i*DIM + j]; } } (a) What would the contents of row be after the Code Listing 2.1 is executed? (b) What would the contents of col be after the Code Listing 2.1 is executed? (c) What would the contents of diag be after the Code Listing 2.1 is executed?

Explanation / Answer

Please rate it: row[]={0,0,0}; int col[]={0,0,0}; int diag[]={0,0}; int mask[]= { 1, 0, 3, 0, 2, 2, 3, 2, -1}; int i,j; const int DIM = 3; for (i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote