initialising multiple matrices in the same loops in c

Here’s your problem:

if (i < q)  B[i][j] = i - j;

The first dimension of B has size p i.e. 3, not q i.e. 4, so when i is 3 you write past the end of B‘s first dimension. This should instead be:

if (i < p)  B[i][j] = i - j;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top