I'm getting three errors:
- Assignment makes integer from pointer without a cast
- Passing argument 1 of
read
from incompatible pointer type - Expected
int * (*)[10]
but argument is of typeint (*)[10][10]
Here is the code:
#include <stdio.h>
#include <stdlib.h>
void read(int *(arr[10][10]), int row, int col) { //Third error here
int i, j;
for (i = 0; i < row; i++)
for (j = 0; j < col; j++)
scanf("%d", &arr[i][j]);
}
void multiply(int arr1[10][10], int row1, int col1,
int arr2[10][10], int row2, int col2,
int *prod[10][10]) { //Third error here
int i, j, k, temp;
for (i = 0; i < row1; i++)
for (j = 0; j < col2; j++) {
temp = 0;
for (k = 0; k < col1; k++)
temp += arr1[i][k] * arr2[k][j];
prod[i][j] = temp; //First error here
}
}
void display(int arr[10][10], int row, int col) {
int i, j;
for (i = 0; i < row; i++) {
for (j = 0; j <col; j++)
printf("%d\t",arr[i][j]);
printf("\n");
}
}
int main() {
int a[10][10], b[10][10], c[10][10], m, n, p, q, i, j, k;
printf("Enter the order of matrix A:");
scanf("%d %d", &m, &n);
printf("Enter the order of matrix B:");
scanf("%d %d", &p, &q);
if (n != p) {
printf("Matrix multiplication is not possible.");
exit(0);
}
printf("Enter the elements of matrix A:\n");
read(&a, m, n); //Second error here
printf("Enter the elements of matrix B:\n");
read(&b, p, q); //Second error here
multiply(a, m, n, b, p, q, &c);
printf("Matrix A is:\n");
display(a, m, n);
printf("Matrix B is:\n");
display(b, p, q);
printf("Product matrix is:\n");
display(c, m, q);
return 0;
}