Multiplying a Matrix with its Transpose
Barring any compiler heroics, you are computing n*n a total of \$n^3\$ times.  You might want to cache that result.

const int nn = n*n;




B[j + n_times_i] is a linearly increasing address location, given that j increases by 1 for each middle loop, and and i increases once for each outer loop, which is n increases of j.  Taking advantage of that, you can skip the j + n*i calculation, and B[ ] indexing.

int *pB  = &amp;B;
// ... loops &amp; calculation of temp omitted for brevity.
      *pB++ = temp;




Result:

const int nn = n*n;
int *pB = B;

for (int i = 0; i &lt; n; i++) {
    for (int j = 0; j &lt; n; j++) {
        temp = 0;
        for (int k = 0; k &lt; nn; k += n) {
            temp += A[i+k] * A[j+k];
        }
        *pB++ = temp;
    }
}




You may find that you can get additional speed by using pointer arithmetic for A[i+k] and A[j+k].

int *pAi = A + i;
int *pAj = A + j;
for (k=0; k&lt;n; k++) {   // Note: n.  The nn variable is no longer needed.
    temp += *pAi * *pAj;
    pAi += n;
    pAj += n;
}


But, you’ll need to profile to find out.  It depends on the number of free registers you have ... and the compiler/optimizers these days are pretty darn good.