1. ## MATRIX multiplication

whats the error in the code ?

Code:
```// MATRIX MULTIPLICATION

#include<stdio.h>
# define MAXROWS 20
# define MAXCOLS 30

void readinput (int a[][MAXCOLS], int nrows, int ncols );
void computesums (int a[][MAXCOLS], int b[][MAXCOLS], int c[][MAXCOLS], int nrows, int ncols);
void writeoutput ( int c[][MAXCOLS] , int nrows, int ncols);
void main()
{

int nrows, ncols,t;
int a[MAXROWS][MAXCOLS],  b[MAXROWS][MAXCOLS] ,  c[MAXROWS][MAXCOLS] ;

printf("Enter the no. of rows and columns of the first matrix");
printf("How many rows?");
scanf("%d", &nrows);
printf("How many columns?");
scanf("%d", &t);
printf("\n\nFirst matrix:\n");

printf("Enter the no. of rows and columns of the Second matrix");
printf("How many rows?");
scanf("%d", &t );
printf("How many columns?");
scanf("%d", & ncols);
printf("\n\nSecond matrix:\n");

computesums (a,b,c,t);

printf("\nMultiplication of the elements:\n\n");

writeoutput(c, nrows, ncols);

}

void readinput( int a[][MAXCOLS], int m , int n)

{

int row,col ;
for(row=0;row<m; ++ row)
{
printf("\nEnter the data for row no. %d\n", row+1);
for(col=0;col<n;++col)
scanf("%d", &a[row][col]);
}
return;

}

void computesums( int a[][MAXCOLS] , int b[][MAXCOLS], int c[][MAXCOLS], int f)

{
int row, col;
for(row=0; row<f;++row)
for(col=0; col<f;++col)

for(int i=0;i<f;++i)

{   c[row][col]=0;
c[row][col]+=a[row][i]*b[i][col] ;
}
return;
}
void writeoutput( int c[][MAXCOLS], int m, int n)

{
int row, col;
for(row=0;row<m;++ row)

{ for(col=0; col<n;++col)
printf("%d ", c[row][col]);
printf("\n");
}
return;

}```

error C2660: 'computesums' : function does not take 4 parameters
Error executing cl.exe.

2. Code:
`       void computesums (int a[][MAXCOLS], int b[][MAXCOLS], int c[][MAXCOLS], int nrows, int ncols);`
Your function prototype is different from definition.

3. Yep. The first time you define computesums has to match up with the second time you define computesums. Change the argument of the first definition to match the second definition. Alternatively, you can change the argument of the second one to match the first one, and put int f in both.

It's also lacking in general polish; it almost never makes any sense to put two printfs right after each other. If you run it like this, it'll say "Enter the no. of rows and columns of the First matrixHow many rows?", which I trust you do not want at all. Add a line break somewhere in between. As my old information literacy teacher would say, "Computers are stupid! They only do what you tell them to do!".

4. i have edited but the result is still shows error. However, at least the program is running .

Code:
```
// MATRIX MULTIPLICATION

#include<stdio.h>
# define MAXROWS 20
# define MAXCOLS 30

void readinput (int a[][MAXCOLS], int nrows, int ncols );
void computesums (int a[][MAXCOLS], int b[][MAXCOLS], int c[][MAXCOLS], int f, int ncols);
void writeoutput ( int c[][MAXCOLS] , int nrows, int ncols);
void main()
{

int nrows, ncols,t;
int a[MAXROWS][MAXCOLS],  b[MAXROWS][MAXCOLS] ,  c[MAXROWS][MAXCOLS] ;

printf("Enter the no. of rows and columns of the first matrix\n");
printf("How many rows?");
scanf("%d", &nrows);
printf("How many columns?");
scanf("%d", &t);
printf("\n\nFirst matrix:\n");

printf("Enter the no. of rows and columns of the Second matrix\n");
printf("How many rows?");
scanf("%d", &t );
printf("How many columns?");
scanf("%d", & ncols);
printf("\n\nSecond matrix:\n");

computesums (a,b,c,nrows, ncols);

printf("\nMultiplication of the elements:\n\n");

writeoutput(c, nrows, ncols);

}

void readinput( int a[][MAXCOLS], int m , int n)

{

int row,col ;

for(row=0;row<m; ++ row)
{
printf("\nEnter the data for row no. %d\n", row+1);
for(col=0;col<n;++col)
scanf("%d", &a[row][col]);
}
return;

}

void computesums( int a[][MAXCOLS] , int b[][MAXCOLS], int c[][MAXCOLS], int f, int ncols)

{
int row, col;
for(row=0; row<f;++row)
for(col=0; col<ncols;++col)

for(int i=0;i<f;++i)

{

int j;

c[row][col]=0;

j=a[row][i]*b[i][col] ;

c[row][col]+=j;

}

return;
}

void writeoutput( int c[][MAXCOLS], int m, int n)

{
int row, col;
for(row=0;row<m;++ row)

{
for(col=0; col<n;++col)

printf("%d ", c[row][col]);
printf("\n");

}

return;

}```

And , lastly , mszegedy @ what you are doing in that extreme cold or its just a joke ?

5. What kind of error?
Give your input, expected output, actual output.

6. Code:
```   for(row=0; row<f;++row) {
for(col=0; col<ncols;++col) {
c[row][col]=0;            /*  move to here */
for(int i=0;i<f;++i) {
int j;
/* c[row][col] = 0;         */
j=a[row][i]*b[i][col] ;

c[row][col]+=j;

}
}
}```

7. Bayint Naung @ THANKS YOU VERY MUCH . ITS WORKING NOW.