#include <stdio.h>

#define DIM1 2
#define DIM2 3

/* Program to multiply 2 matrices together of the form. Ferworn F00

		columns
    	r|a00 a01 a02| 	  |b00 b01|
a = 	o|a10 a11 a12|  b = |b10 b11|
	w			  |b20 b21|
	s			   

result will be a 2 x 2 matrix	result = 	|r00 r01|
							|r10 r11|
r00 = a00*b00 + a01*b10 + a02*b20
r01 = a00*b01 + a01*b11 + a02*b21
r10 = a10*b00 + a11*b10 + a12*b20
r11 = a10*b01 + a11*b11 + a12*b21

*/
void main()
{
	int a[DIM1][DIM2] = {{1,2,3},
						 {4,5,6}};
	int b[DIM2][DIM1] ={{10,10},
					 	{10,10},
						{10,10}};
	int result[DIM1][DIM1];
	int i,j,k,temp;
	
	/* These two loops step through each element of the matrix
	   going along each row from one column to the next */
	   
	for(i=0;i<DIM1;i++)
		for(j=0;j<DIM1;j++)
		{
			temp = 0;	/* temp will accumulate the answer */
			
			/* This loop forms the dot product */
			for(k=0;k<DIM2;k++)
				temp = temp + a[i][k] * b[k][j];
				
			result[i][j] = temp; /* store the dot product */
		}
	
	/* These loops will print out the result */
	
	for(i=0;i<DIM1;i++)
	{
		printf("\n");
		for(j=0;j<DIM1;j++)
			printf("%d\t",result[i][j]);
	}
}