-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQ-19.c
37 lines (33 loc) · 771 Bytes
/
Q-19.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
#include<stdio.h>
void main() {
int rows, cols, i,j;
printf("Enter number of rows: ");
scanf("%d",&rows);
printf("Enter number of columns: ");
scanf("%d",&cols);
int a[rows][cols], b[rows][cols], c[rows][cols];
printf("Enter Elements of 1st Matrix: \n");
for(i=0; i < rows; i++) {
for(j=0; j < cols; j++) {
scanf("%d",&a[i][j]);
}
}
printf("Enter Elements of 2nd Matrix: \n");
for(i=0; i < rows; i++) {
for(j=0; j < cols; j++) {
scanf("%d",&b[i][j]);
}
}
for(i=0; i < rows; i++) {
for(j=0; j < cols; j++) {
c[i][j] = a[i][j] - b[i][j];
}
}
printf("\n\nDIFFERENCE OF TWO MATRICES:\n");
for(i=0; i < rows; i++) {
for(j=0; j < cols; j++) {
printf("%d ",c[i][j]);
}
printf("\n");
}
}