Hello,

I've just started learning C, and now I have a problem (and I couldn't find a solution on the interweb ;) ).

I want to multiply two matrices (2x2). First it 'reads' two matrices, and after that it needs to multiply it.

It reads the matrices using double for-loops; this works great. However, now I want to multiply the values of both matrices, but I can't access the variables outside the for-loops. I tried adding 'static' or 'extern' keywords before the declaration of the matrix, but that doesn't help...

Any idea would be greatly appreciated.

Thanks,

```
#include <stdio.h>
int main()
{
printf("Multiply two square matrices\n");
printf("What's the size of the matrix?\n");
int size;
scanf("%d", &size);
while (size!=2)
{
printf("Only 2x2 matrices allowed at the time.\n");
printf("Just answer 2 here ^^ .\n");
scanf("%d", &size);
}
printf("First, matrix A\n");
int i,j;
for (i = 1; i <=size; i++)
{
for (j = 1; j <=size ; j++)
{
printf("What is element [%d][%d]", i, j);
float elementA[i][j];
scanf("%f", &elementA[i][j]);
printf("elelemnt [%d][%d] is %f\n", i,j,elementA[i][j]);
}
}
printf("Second, matrix B\n");
int k,m;
for (k = 1; k <=size; k++)
{
for (m = 1; m <=size ; m++)
{
printf("What is element [%d][%d]", k,m);
float elementB[k][m];
scanf("%f", &elementB[k][m]);
printf("elelement [%d][%d] is %f\n", k,m,elementB[k][m]);
}
}
newmatrix[1][2]=elementA[1][1]*elementB[1][2] +elementA[1][2]*elementB[2][2]; /* This doesn't work /*
}
```