-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproblem-33.c
68 lines (61 loc) · 1.5 KB
/
problem-33.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @file matrixMultiplication.c
* Matrix multiplication
* @author Md. Alamin ([email protected])
* I would love be a software engineer at Google. That is why anybody can uses this code without any condition, if you face any difficulty, then try to email me.
* @version 0.1
* @date 2022-03-24
*
* @copyright Copyright (c) 2022
*
*/
#include <stdio.h>
void main()
{
int n, r, c, k, sum = 0;
printf("Enter matrix size: ");
scanf("%d", &n);
int m1[n][n], m2[n][n], mul[n][n];
printf("Enter matrix 1 value: ");
for(r=0; r<n; r++){
for(c=0; c<n; c++){
scanf("%d", &m1[r][c]);
}
}
printf("Enter matrix 2 value: ");
for(r=0; r<n; r++){
for(c=0; c<n; c++){
scanf("%d", &m2[r][c]);
}
}
printf("\nmatrix 1 value: \n");
for(r=0; r<n; r++){
for(c=0; c<n; c++){
printf("%d\t", m1[r][c]);
}
printf("\n");
}
printf("\nmatrix 2 value: \n");
for(r=0; r<n; r++){
for(c=0; c<n; c++){
printf("%d\t", m2[r][c]);
}
printf("\n");
}
printf("\nMultiplication value of matrix 1 and Matrix 2 is: \n");
for(r=0; r<n; r++){
for(c=0; c<n; c++){
for(k=0; k<n; k++){
sum = sum + m1[r][k] * m2[k][c];
}
mul[r][c] = sum;
sum = 0;
}
}
for(r=0; r<n; r++){
for(c=0; c<n; c++){
printf("%d\t", mul[r][c]);
}
printf("\n");
}
}