-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode
61 lines (58 loc) · 1.39 KB
/
Code
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
#include<stdio.h>
void main()
{
int a,m, n, c, d,x[10][10],y[10][10],z[10][10];
printf("Enter the number of rows: ");
scanf("%d", & m);
printf("Enter the number of columns: ");
scanf("%d", & n);
printf("\n");
printf("Enter the elements of first matrix\n");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
{
printf("\nx[%d][%d]:",c,d);
scanf("%d", & x[c][d]);
}
printf("\n");
printf("Enter the elements of second matrix\n");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
{
printf("\nx[%d][%d]:",c,d);
scanf("%d", & y[c][d]);
}
{
printf("\n");
printf("for addition enter 1\n");
printf("for subtraction enter 2\n");
scanf("%d",&a);
switch(a)
{
case 1:
printf("Sum of entered matrices:-\n\n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
z[c][d] = x[c][d] + y[c][d];
printf("%d\t", z[c][d]);
}
printf("\n");
}
break;
case 2:
printf("subtraction of entered matrices:-\n\n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
z[c][d] = x[c][d] - y[c][d];
printf("%d\t", z[c][d]);
}
printf("\n");
}
break;
}
}
}