-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lecture17 MultidimensionalArrays2.c
64 lines (48 loc) · 1.33 KB
/
Lecture17 MultidimensionalArrays2.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>
#include <stdlib.h>
//Written by Bunyamin Yavuz in 2022
//Multidimensional Arrays
int main()
{
// Summation of matrices (They must have same size (Rule))
// Get size of matrices
int row1,column1,row2,column2;
int i,j,k,z;
printf("Rows number of first matric ? ");
scanf("%d",&row1);
printf("Columns number of first matric ? ");
scanf("%d",&column1);
printf("Rows number of second matric ? ");
scanf("%d",&row2);
printf("Columns number of first matric ? ");
scanf("%d",&column2);
int matric1[row1][column1];
int matric2[row2][column2];
// Get the first matric from keyboard
for(i = 0;i < row1; i++)
{
for(j = 0; j < column1; j++)
{
printf("Enter the element of [%d][%d] first matric: ",i+1,j+1);
scanf("%d",&matric1[i][j]);
}
}
// Get the second matric from the keyboard
for(k = 0; k < row2; k++)
{
for(z = 0; z < column2; z++)
{
printf("Enter the element of [%d][%d] second matric: ",k+1,z+1);
scanf("%d",&matric2[k][z]);
}
}
// Sum the matrices
for(int i = 0; i < row1; i++)
{
for(j = 0; j < column1; j++)
{
printf("%d ",(matric1[i][j])+(matric2[i][j]));
}printf("\n");
}
return 0;
}