-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexam_practise.c
More file actions
51 lines (43 loc) · 1.1 KB
/
exam_practise.c
File metadata and controls
51 lines (43 loc) · 1.1 KB
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
#include<stdio.h>
int main(){
int max = 50;
int A[max][max];
int B[max][max];
int m,n;
int sum[max][max];
int sub[max][max];
printf("matrix a: ");
printf("Enter the row of matrix A: ");
scanf("%d",&m);
printf("Enter the column of matrix A: ");
scanf("%d",&n);
for(int i = 1;i<=m;i++){
for(int j = 1;j<=n;j++){
printf("Enter the [%d][%d]: ",i,j);
scanf("%d",&A[i][j]);
}
}
for(int i = 1;i<=m;i++){
for(int j = 1;j<=n;j++){
printf("Enter the [%d][%d]: ",i,j);
scanf("%d",&B[i][j]);
}
}
printf("The sum of the matrix are below\n");
for(int i = 1;i<=m;i++){
for(int j = 1;j<=n;j++){
sum[i][j] = A[i][j]+B[i][j];
printf("%d\t",sum[i][j]);
}
printf("\n");
}
printf("The subtraction of the matrix are below\n");
for(int i = 1;i<=m;i++){
for(int j = 1;j<=n;j++){
sub[i][j] = A[i][j]-B[i][j];
printf("%d\t",sub[i][j]);
}
printf("\n");
}
return 0;
}