-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q38.c
55 lines (45 loc) · 1.08 KB
/
Q38.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
//C program to perform scalar matrix multiplication
//C program to perform scalar matrix multiplication
#include<stdio.h>
int main()
{
int m,n,i,j,k;
int a[10][10],b[10][10],c[10][10],sum[10][10];
printf("Enter the order of square matrix :");
scanf("%d",&m);
printf("Enter the %d elements of 1st square matrix :",m*m);
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the %d elements of 2nd square matrix :",m*m);
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{ sum[i][j]=0;
for(k=0;k<m;k++)
{
sum[i][j]+=a[i][k]*b[k][j];
}
}
}
printf("Multiplication of two scaler matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
printf("%d ",sum[i][j]);
}
printf("\n");
}
}