-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQN001.c
47 lines (37 loc) · 779 Bytes
/
QN001.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
/**
* Write a program to add two matrices using array.
*/
#include <stdio.h>
int main()
{
int a, b, i, j, first[10][10], second[10][10], sum[10][10];
printf("Enter the number of rows and columns: ");
scanf("%d%d", &a, &b);
printf("Enter the value for first matrix: ");
for (i = 0; i < a; i++)
{
for (j = 0; j < b; j++)
{
scanf("%d", &first[i][j]);
}
}
printf("Enter the value for second matrix: ");
for (i = 0; i < a; i++)
{
for (j = 0; j < b; j++)
{
scanf("%d", &second[i][j]);
}
}
printf("Sum of entered matrices:\n");
for (i = 0; i < a; i++)
{
for (j = 0; j < b; j++)
{
sum[i][j] = first[i][j] + second[i][j];
printf("%d\t", sum[i][j]);
}
printf("\n");
}
return 0;
}