Consider the system of equations as Ax = B where A is the coefficient matrix and B is the constant matrix.
In your code, the matrices a,b correspond to the matrices A, B after Gaussian elimination. For i = n, the value of j is n+1. Hence, the code inside second for loop is not executed. When j = n (the code inside second for loop run for the first time), the value of x(j) is defined as
x(j) = x(n) = b(n)/a(n,n);
And the remaining indices (1:n) of x are set to zero. The values of x for index < n is obtained by using the previous index value. For example, x(n) is used in the computation of x(n-1).
