-
Notifications
You must be signed in to change notification settings - Fork 0
/
SUM2DARR.C
58 lines (58 loc) · 1.07 KB
/
SUM2DARR.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
#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2],b[2][2],c[2][2];
int i,j;
clrscr();
printf("Enter the first matrix element value:");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the second matrix element value:");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
//Adding of Matrix
printf("Sum of matrix element is\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\t%d",c[i][j]);
}
printf("\n");
}
//Substraction of 2D Matrix
printf("Sub of matrix element is\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]-b[i][j];
printf("\t%d",c[i][j]);
}
printf("\n");
}
//Multiplication of 2D Matrix
printf("Mult of matrix element is\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]*b[i][j];
printf("\t%d",c[i][j]);
}
printf("\n");
}
getch();
}