How is the formula for calculation in row/column major obtained?
Row-major order stores the rows of the array one after another in memory. That is, the array

a d g j
b e h k
c f i l


is stored as

a d g j b e h k c f i l


To determine the address of an element in this list, we need to know how many elements come before it. For element $[I,J]$, this is the number of complete rows above row&nbsp;$I$ times the length of a row, which is $(I-L_r)\times n$, plus the number of elements before it in the current row, which is $J-L_c$.

Since the first element is at address&nbsp;$B$ and each element takes $W$&nbsp;bytes, the addresses of the elements are $B$, $B+W$, $B+2W$, ... and, in general, if there are $k$&nbsp;elements before you, your address is $B+kW$. For element $[I,J]$, we have calculated that $k=n(I-L_r)+(J-L_c)$.

For column-major, the argument is basically the same. If you understand the above, it should be easy to adapt it.