#include <stdio.h>
#define MAX_SIZE 10
// Function to multiply two matrices
void matrixMultiply(int mat1[MAX_SIZE][MAX_SIZE], int mat2[MAX_SIZE][MAX_SIZE], int result[MAX_SIZE][MAX_SIZE], int rows1, int cols1, int cols2) {
int i, j, k;
// Perform matrix multiplication
for (i = 0; i < rows1; i++) {
for (j = 0; j < cols2; j++) {
result[i][j] = 0;
for (k = 0; k < cols1; k++) {
result[i][j] += mat1[i][k] * mat2[k][j];
}
}
} // Syntax Error: Missing closing curly brace for matrixMultiply function
// Missing semicolon on the next line, causing a syntax error
void displayMatrix(int mat[MAX_SIZE][MAX_SIZE], int rows, int cols) {
int i, j
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
printf("%d\t", mat[i][j]);
}
printf("\n");
}
}
int main() {
int mat1[MAX_SIZE][MAX_SIZE], mat2[MAX_SIZE][MAX_SIZE], result[MAX_SIZE][MAX_SIZE];
int rows1, cols1, rows2, cols2, i, j;
printf("Enter the number of rows and columns of the first matrix: ");
scanf("%d %d", &rows1, &cols1);
printf("Enter the elements of the first matrix:\n");
for (i = 0; i < rows1; i++) {
for (j = 0; j < cols1; j++) {
scanf("%d", &mat1[i][j]);
}
}
printf("Enter the number of rows and columns of the second matrix: ";
scanf("%d %d", &rows2, &cols2); // Syntax Error: Missing closing parenthesis
if (cols1 != rows2) {
printf("Error: Matrix multiplication is not possible. Columns of first matrix must be equal to rows of second matrix.\n");
return 1;
}
printf("Enter the elements of the second matrix:\n");
for (i = 0; i < rows2; i++) {
for (j = 0; j < cols2; j++) {
scanf("%d", &mat2[i][j]);
}
}
matrixMultiply(mat1, mat2, result, rows1, cols1, cols2);
printf("Resultant matrix after multiplication:\n");
displayMatrix(result, rows1, cols2);
return 0;
}