-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes.c
More file actions
89 lines (73 loc) · 1.86 KB
/
Notes.c
File metadata and controls
89 lines (73 loc) · 1.86 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <stdlib.h>
#define LIMIT 20
int arrA[LIMIT][LIMIT];
int arrB[LIMIT][LIMIT];
int arrC[LIMIT][LIMIT];
void pushB(int a,int b){ //to enter elements in B
int u;
for (int w=1;w<=a;w++){
for(int q=1;q<=b;q++){
printf("enter element a(%d,%d)",w,q);
scanf("%d",&u);
arrB[w][q]=u;
}
}
}
void sum(int a,int b){ //to compute sum
for(int w=1;w<=a;w++){
for(int q=1;q<=b;q++){
arrC[w][q]=(arrA[w][q])+(arrB[w][q]);
}
}
}
void pushA(int a,int b){ //to enter elements in A
int u;
for (int w=1;w<=a;w++){
for(int q=1;q<=b;q++){
printf("enter element a(%d,%d)",w,q);
scanf("%d",&u);
arrA[w][q]=u;
}
}
}
void print(int a,int b){ //to print the sum
for (int w=1;w<=a;w++){
for(int q=1;q<=b;q++){
printf("sum(%d,%d)=%d\n",w,q,arrC[w][q]);
}
}
}
int main(){
int x,i,j;
printf("enter i:");
scanf("%d",&i);
printf("enter j:");
scanf("%d",&j);
while(1){
printf("1.Add elements in A:\n");
printf("2.Add elements in B:\n");
printf("3.Sum of elements:\n");
printf("4.Display elements:\n");
printf("5.Exit\n");
scanf("%d",&x);
switch(x){
case 1:
pushA(i,j);
break;
case 2:
pushB(i,j);
break;
case 3:
sum(i,j);
break;
case 4:
print(i,j);
break;
case 5:
exit(0);
default:
printf("invalid");
}
}
}