[Solved] Draw the array referred by the reference u [closed]


The answer is:

 u[0] = 6, u[1] = 9, u[2] = 12

I will explain how the loop goes.

  for (int i = 0; i < u.length; i++){   
       u[i] = b[0][i];
  for (int j = 1; j < b.length; j++)
       u[i] += b[j][i];
      }

First loop:

 outer for loop:
 u[i] = b[0][i]; --> u[0] = 1

 inner for loop:
 u[i] += b[j][i] --> u[0] += b[1][0] so --> u[0] = 1 + 2 --> u[0]=3

 second loop in inner for loop:

 "now j = 2"
  u[0] += b[2][0] --> u[0] = 3 + 3 --> u[0] = 6

that’s how it does. Just repeat on u[1] and u[2]

3

solved Draw the array referred by the reference u [closed]