Get Website Learn Coding Tech Story

C Programming Examples

#include<stdio.h>

int main() {

	/* Declaration of two dimensional array */
	int a[3][3], b[3][3], c[3][3], i, j, k;
	printf("Enter value for 1st matrix:\n");
	for(i = 0; i < 3; i++)
		for(j = 0; j < 3; j++)
			scanf("%d", &a[i][j]);
	printf("Enter value for 2nd matrix:\n");
	for(i = 0; i < 3; i++)
		for(j = 0; j < 3; j++)
			scanf("%d", &b[i][j]);

	/* Multiplication of two matrix */
	for(i = 0; i < 3; i++)
		for(j = 0; j < 3; j++) {
			c[i][j] = 0;
			for(k = 0; k < 3; k++)
				c[i][j] += a[i][k] * b[k][j];
		}
	printf("After multiplication of two 3x3 matrix:\n");
	for(i = 0; i < 3; i++) {
		for(j = 0; j < 3; j++)
			printf("%d\t",c[i][j]);
			printf("\n");
	}
	return 0;
}


          /****** Output ******/
          

Enter value for 1st matrix:


1


2


3


4


5


6


7


8


9


Enter value for 2nd matrix:


1


2


3


4


5


6


7


8


9


After multiplication of two 3x3 matrix:


30  36  42


66  81  96


102 126 150

Learn more about Matrix Multiplication