File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ //addition of matrix or subtraction of matrix
2+ #include<stdio.h>
3+ int main()
4+ {
5+ int a[10][10],b[10][10],x[10][10];
6+ int r,c;
7+ printf("\n Enter the order of matrix a (max 10x10):");
8+ scanf("%d%d",&r,&c);
9+ printf("enter the elements of matrix a: ");
10+ for (int i=0;i<r;i++)
11+ for (int j=0;j<c;j++)
12+ scanf("%d",&a[i][j]);
13+ printf("\n enter the elements of matrix b: ");
14+ for (int i=0;i<r;i++)
15+ for (int j=0;j<c;j++)
16+ scanf("%d",&b[i][j]);
17+
18+ for(int i=0;i<r;i++)
19+ for(int j=0;j<c;j++)
20+ x[i][j]=a[i][j]+b[i][j]; //for addition
21+ //x[i][j]=a[i][j]-b[i][j]; for subtraction
22+
23+ printf("now the elements of the resultant matrix x is: ");
24+ for(int i=0;i<r;i++)
25+ {
26+ for(int j=0;j<c;j++)
27+ printf(" %d",x[i][j]);
28+ printf("\n");
29+ }
30+ return 0;
31+
32+ }
Original file line number Diff line number Diff line change 1+ //addition of matrix or subtraction of matrix
2+ #include<stdio.h>
3+ int main()
4+ {
5+ int a[10][10],b[10][10],x[10][10];
6+ int r,c;
7+ printf("\n Enter the order of matrix a (max 10x10):");
8+ scanf("%d%d",&r,&c);
9+ printf("enter the elements of matrix a: ");
10+ for (int i=0;i<r;i++)
11+ for (int j=0;j<c;j++)
12+ scanf("%d",&a[i][j]);
13+ printf("\n enter the elements of matrix b: ");
14+ for (int i=0;i<r;i++)
15+ for (int j=0;j<c;j++)
16+ scanf("%d",&b[i][j]);
17+
18+ for(int i=0;i<r;i++)
19+ for(int j=0;j<c;j++)
20+ //x[i][j]=a[i][j]+b[i][j]; //for addition
21+ x[i][j]=a[i][j]-b[i][j]; //for subtraction
22+
23+ printf("now the elements of the resultant matrix x is: ");
24+ for(int i=0;i<r;i++)
25+ {
26+ for(int j=0;j<c;j++)
27+ printf(" %d",x[i][j]);
28+ printf("\n");
29+ }
30+ return 0;
31+
32+ }
You can’t perform that action at this time.
0 commit comments