-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix multiplication.c
52 lines (46 loc) · 1.09 KB
/
matrix multiplication.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
int main()
{
int matrix_a[3][3], matrix_b[3][3], finale_matrix[3][3] = {0}, i, j, k;
printf("For Matrix A\n");
printf("Enter row elements 1 by 1:\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
printf("Enter A[%d][%d]", i + 1, j + 1);
scanf("%d", &matrix_a[i][j]);
}
}
printf("--------------------------\n");
printf("For Matrix B\n");
printf("Enter row elements 1 by 1:\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
printf("Enter A[%d][%d]", i + 1, j + 1);
scanf("%d", &matrix_b[i][j]);
}
}
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
for (k = 0; k < 3; k++)
{
finale_matrix[i][j] += matrix_a[i][k] * matrix_b[k][j];
}
}
}
printf("\nA x B:\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
printf("%d ", finale_matrix[i][j]);
}
printf("\n");
}
return 0;
}