[ Prev ]
2021-11-03

-- Nov 2 In-Class Exercise Thread
 The C compiler will allocate 3 rows * 4 columns * 4 bytes = 48 bytes for the 2-dimensional
 array.
 The values could be stored in a single array where the rows are written one after another.
 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
 In memory at a[0][3]:
 0000 0000 0000 0000 0000 0000 0000 0011
(Edited: 2021-11-03)
The C compiler will allocate 3 rows * 4 columns * 4 bytes = 48 bytes for the 2-dimensional array. The values could be stored in a single array where the rows are written one after another. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} In memory at a[0][3]: 0000 0000 0000 0000 0000 0000 0000 0011

-- Nov 2 In-Class Exercise Thread
Resource Description for 20211103_184348.jpg
((resource:20211103_184348.jpg|Resource Description for 20211103_184348.jpg))

-- Nov 2 In-Class Exercise Thread
Memory that is allocated by the C compiler for this array would be 3 rows * 4 columns * 4 bytes = 48 bytes.
Values written in memory: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
(Edited: 2021-11-03)
Memory that is allocated by the C compiler for this array would be 3 rows * 4 columns * 4 bytes = 48 bytes. Values written in memory: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}

-- Nov 2 In-Class Exercise Thread
int a[3][4] = { {0, 1, 2, 3} , {4, 5, 6, 7} , {8, 9, 10, 11} }; There are 12 integers in this array, each integer takes up 4 bytes in memory. C compiler would allocate 48 bytes of memory for this array. The values written in memory are stored one row following another. 0 1 2 3 4 5 6 7 8 9 10 11 as binary bits. So 0 = 00000000 00000000 00000000 00000000 1 = 00000000 00000000 00000000 00000001 ... 11= 00000000 00000000 00000000 00001011
<nowiki> int a[3][4] = { {0, 1, 2, 3} , {4, 5, 6, 7} , {8, 9, 10, 11} }; There are 12 integers in this array, each integer takes up 4 bytes in memory. C compiler would allocate 48 bytes of memory for this array. The values written in memory are stored one row following another. 0 1 2 3 4 5 6 7 8 9 10 11 as binary bits. So 0 = 00000000 00000000 00000000 00000000 1 = 00000000 00000000 00000000 00000001 ... 11= 00000000 00000000 00000000 00001011 </nowiki>

-- Nov 2 In-Class Exercise Thread
Because the array has 3*4=12 integers and each integer takes 4 bytes there will be 12*4=48 bytes of memory.
The values would be written in memory row by row, so [0,1,2,3,4,5,6,7,8,9,10,11]. The bytes at a[0][2] would be 0000 0000 0000 0000 0000 0000 0000 0002
Because the array has 3*4=12 integers and each integer takes 4 bytes there will be 12*4=48 bytes of memory. The values would be written in memory row by row, so [0,1,2,3,4,5,6,7,8,9,10,11]. The bytes at a[0][2] would be 0000 0000 0000 0000 0000 0000 0000 0002
2021-11-06

-- Nov 2 In-Class Exercise Thread
How much memory would be allocated by the C compiler for this array? 3 * 4 * 4 = 48 bytes How would the values be written in memory? It will write the first row into the first n elements, second into the next... and so on
How much memory would be allocated by the C compiler for this array? 3 * 4 * 4 = 48 bytes How would the values be written in memory? It will write the first row into the first n elements, second into the next... and so on
2021-11-08

-- Nov 2 In-Class Exercise Thread
3 x 4 = 12 elements each int takes 4 bytes 4 x 12 = 48 bytes Array written in memory as: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
<nowiki>3 x 4 = 12 elements each int takes 4 bytes 4 x 12 = 48 bytes Array written in memory as: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11</nowiki>

-- Nov 2 In-Class Exercise Thread
 There is 4 byte for int. 
 Then int a[3][4]will take 12 x 4 = 48 byte
 Value that will write to memory is {0, 1, 2, 3 4, 5, 6, 7, 8, 9, 10, 11, 12 }
 Ex. In memory 
 0000 0000 0000 0000 0000 0000 0000 0000|
 0000 0000 0000 0000 0000 0000 0000 0001|
 0000 0000 0000 0000 0000 0000 0000 0010
(Edited: 2021-11-08)
There is 4 byte for int. Then int a[3][4]will take 12 x 4 = 48 byte Value that will write to memory is {0, 1, 2, 3 4, 5, 6, 7, 8, 9, 10, 11, 12 } Ex. In memory 0000 0000 0000 0000 0000 0000 0000 0000| 0000 0000 0000 0000 0000 0000 0000 0001| 0000 0000 0000 0000 0000 0000 0000 0010

-- Nov 2 In-Class Exercise Thread
There are 12 integers in the 3 by 4 array, and each integer hold 4 bytes of memory. So the C compiler will allocate 48 bytes of memory for the given array. The values would be saved into a single row of memory from 0-11. The values would be saved in 16 bit binary.
There are 12 integers in the 3 by 4 array, and each integer hold 4 bytes of memory. So the C compiler will allocate 48 bytes of memory for the given array. The values would be saved into a single row of memory from 0-11. The values would be saved in 16 bit binary.

-- Nov 2 In-Class Exercise Thread
Number of bytes allocated: 3(rows) * 4(cols) * 4(int) = 48 bytes 
 
The values will be stored in consecutive memory slots in the memory.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 
<pre> Number of bytes allocated: 3(rows) * 4(cols) * 4(int) = 48 bytes The values will be stored in consecutive memory slots in the memory. 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 </pre>
[ Next ]
X