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");
readinput(a,nrows,t);
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");
readinput(b,t,ncols);
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 ?