-
Notifications
You must be signed in to change notification settings - Fork 16
/
15.c
64 lines (54 loc) · 1.78 KB
/
15.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
int main()
{
int element_number_of_matrix;
printf("Enter element number of matrix: ");
scanf("%d", &element_number_of_matrix);
int first_matrix[element_number_of_matrix][element_number_of_matrix];
int second_matrix[element_number_of_matrix][element_number_of_matrix];
int i, j;
for ( i = 0; i < element_number_of_matrix; i++ )
{
for ( j = 0; j < element_number_of_matrix; j++ )
{
printf("Enter row %d and column %d of first matrix: ", i+1, j+1);
scanf("%d", &first_matrix[i][j]);
}
}
for ( i = 0; i < element_number_of_matrix; i++ )
{
for ( j = 0; j < element_number_of_matrix; j++ )
{
printf("Enter row %d and column %d of second matrix: ", i+1, j+1);
scanf("%d", &second_matrix[i][j]);
}
}
int summed_matrix[element_number_of_matrix][element_number_of_matrix];
int substraction_matrix[element_number_of_matrix][element_number_of_matrix];
for ( i = 0; i < element_number_of_matrix; i++ )
{
for ( j = 0; j < element_number_of_matrix; j++ )
{
summed_matrix[i][j] = first_matrix[i][j] + second_matrix[i][j];
substraction_matrix[i][j] = first_matrix[i][j] - second_matrix[i][j];
}
}
printf("Summed matrix: \n");
for ( i = 0; i < element_number_of_matrix; i++ )
{
for ( j = 0; j < element_number_of_matrix; j++ )
{
printf("%d ", summed_matrix[i][j]);
}
printf("\n");
}
printf("Substraction matrix: \n");
for ( i = 0; i < element_number_of_matrix; i++ )
{
for ( j = 0; j < element_number_of_matrix; j++ )
{
printf("%d ", substraction_matrix[i][j]);
}
printf("\n");
}
}