-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloc_q5.c
63 lines (59 loc) · 1.27 KB
/
loc_q5.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
// 5.initialise two 2*2 matrices and print their sum and product
#include<stdio.h>
int main()
{
int a1[2][2],sum=0,a2[2][2],p=1;
printf("Enter the elements of first matrix:\n");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
scanf("%d",&a1[i][j]);
}
}
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
printf("%d ",a1[i][j]);
}
printf("\n");
}
printf("Enter the elements of second matrix:\n");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
scanf("%d",&a2[i][j]);
}
}
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
printf("%d ",a2[i][j]);
}
printf("\n");
}
printf("Sum :\n");
for(int i =0;i<2;i++)
{
for (int j=0;j<2;j++)
{
sum=a1[i][j]+a2[i][j];
printf("%d ",sum);
}
printf("\n");
}
printf("Product:\n");
for(int i =0;i<2;i++)
{
for (int j=0;j<2;j++)
{
p=a1[i][j]*a2[i][j];
printf("%d ",p);
}
printf("\n");
}
return 0;
}