-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQ7.c
43 lines (40 loc) · 826 Bytes
/
Q7.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
/* Program:- 7
C program to read two matrices of size 3*3 and find their product.
*/
#include <stdio.h>
void main()
{
int matrix_1[3][3], matrix_2[3][3], product[3][3];
int sum, i, j, k;
printf("Enter the first matrix: ");
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
scanf("%d", &matrix_1[i][j]);
}
}
printf("Enter the second matrix: ");
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
scanf("%d", &matrix_2[i][j]);
}
}
printf("\n____product of matrix____\n");
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
sum = 0;
for (int k = 0; k < 3; k++)
{
sum += matrix_1[i][k] * matrix_2[k][j];
}
product[i][j] = sum;
printf("%d\t", product[i][j]);
}
printf("\n");
}
}