Matrix multiplication using functions in C This exercise surprised me a little bit. I did not expect that gcc (GCC 6.3.0 in the MinGW suite) would use the C11 standard by default, which I realised after I read the documentation. Here's the code that compiles without any errors or warnings:

matrix.c

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

void input(int m, int n, int a[m][n])
{
    for (int i = 0; i &lt; m; i++) {
        for (int j = 0; j &lt; n; j++) {
            printf("%d, %d : ", i, j);
            scanf("%d", &amp;a[i][j]);
        }
    }
}

void print(int m, int n, int a[m][n])
{
    int i, j;
    for (i = 0; i &lt; m; i++) {
        for (j = 0; j &lt; n; j++) {
            printf("%3d ", a[i][j]);
        }
        printf("\n");
    }   
}

void multiply(int m, int n, int p, int a[m][n], int b[n][p], int c[m][p])
{
    for (int i = 0; i &lt; m; i++) {
        for (int j = 0; j &lt; p; j++) {
            c[i][j] = 0;
            for (int k = 0; k &lt; n; k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
}

int main()
{
    int r1, c1, r2, c2;
    printf("Row and column for matrix #1 :\n");
    scanf("%d %d", &amp;r1, &amp;c1);
    printf("Row and column for matrix #2 :\n");
    scanf("%d %d", &amp;r2, &amp;c2);

    if (r2 != c1) {
        printf("The matrices are incompatible.\n");
        exit(EXIT_FAILURE);
    }

    int mat1[r1][c1], mat2[r2][c2], ans[r1][c2];
    printf("Enter elements of the first matrix.\n");
    input(r1, c1, mat1);
    printf("The elements of the first matrix are :\n");
    print(r1, c1, mat1);
    printf("Enter elements of the second matrix.\n");
    input(r2, c2, mat2);
    printf("The elements of the second matrix are :\n");
    print(r2, c2, mat2);

    multiply(r1, r2, c2, mat1, mat2, ans);
    printf("The product is :\n");
    print(r1, c2, ans);

    return EXIT_SUCCESS;
}


Feedback and criticism on any and all aspects are welcome.
I suggest you roll an explicit matrix type. For example:

typedef struct matrix_t {
    size_t rows;
    size_t cols;
    int* data;
} matrix_t;

void matrix_t_multiply(matrix_t* left, matrix_t* right, matrix_t* result) {
    ...
}