Compare commits

..

9 Commits

Author SHA1 Message Date
zleyyij
eb0a5d9264 vault backup: 2024-10-08 22:11:53 2024-10-08 22:11:53 -06:00
zleyyij
4b75ea7a74 vault backup: 2024-10-08 22:06:51 2024-10-08 22:06:51 -06:00
zleyyij
9994e1407c vault backup: 2024-10-08 22:01:51 2024-10-08 22:01:51 -06:00
zleyyij
47e79e370d vault backup: 2024-10-08 21:46:22 2024-10-08 21:46:22 -06:00
zleyyij
0281a32394 vault backup: 2024-10-08 21:41:21 2024-10-08 21:41:22 -06:00
zleyyij
3a62a38f44 vault backup: 2024-10-08 21:36:22 2024-10-08 21:36:22 -06:00
zleyyij
df16aedfcd vault backup: 2024-10-08 21:30:42 2024-10-08 21:30:42 -06:00
zleyyij
59fefb4ae7 vault backup: 2024-10-08 21:25:18 2024-10-08 21:25:18 -06:00
zleyyij
1622311f8f vault backup: 2024-10-08 21:20:19 2024-10-08 21:20:19 -06:00
2 changed files with 54 additions and 4 deletions

2
.obsidian/app.json vendored
View File

@ -2,7 +2,7 @@
"vimMode": true, "vimMode": true,
"promptDelete": false, "promptDelete": false,
"pdfExportSettings": { "pdfExportSettings": {
"includeName": false, "includeName": true,
"pageSize": "Letter", "pageSize": "Letter",
"landscape": false, "landscape": false,
"margin": "0", "margin": "0",

View File

@ -5,15 +5,65 @@ Using the type of the array's first element means that if you change the type of
> 3. Write a declaration of an array named weekend containing seven `bool` values. Include an initialize that makes the first and last values `true`; all other values should be `false`. > 3. Write a declaration of an array named weekend containing seven `bool` values. Include an initialize that makes the first and last values `true`; all other values should be `false`.
> 4. Calculators, watches, and other electronic devices often rely on 7 segment displays for numerical output. To form a digit, such devices turn on some of the seven segments while leaving others off. Answer:
```c
bool weekend[] = {true, [1 ... 5] = false, true};
```
> 5. Calculators, watches, and other electronic devices often rely on 7 segment displays for numerical output. To form a digit, such devices turn on some of the seven segments while leaving others off.
> >
> Here's what the array might look like, with each row representing one digit: > Here's what the array might look like, with each row representing one digit:
``` ```c
const int segments[10][7] = {{1, 1, 1, 1, 1, 1, 0}, ...}; const int segments[10][7] = {{1, 1, 1, 1, 1, 1, 0}, ...};
``` ```
> I've given you the first row of the initializer, fill in the rest. > I've given you the first row of the initializer, fill in the rest.
Answer:
```c
const int segments[10][7] = {
{1, 1, 1, 1, 1, 1, 0}, // 0
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 0}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1} // 9
};
```
>10. Write a declaration for an 8x8 `char` array named `chess_board`. Include an initializer that puts the following data into the array, one character per array element: >10. Write a declaration for an 8x8 `char` array named `chess_board`. Include an initializer that puts the following data into the array, one character per array element:
\[omitted] \[omitted]
```c
char chess_board[8][8] = {
{'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'},
{'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'},
{' ', '.', ' ', '.', ' ', '.', ' ', '.'},
{'.', ' ', '.', ' ', '.', ' ', '.', ' '},
{' ', '.', ' ', '.', ' ', '.', ' ', '.'},
{'.', ' ', '.', ' ', '.', ' ', '.', ' '},
{' ', '.', ' ', '.', ' ', '.', ' ', '.'},
{'.', ' ', '.', ' ', '.', ' ', '.', ' '},
{'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'},
{'R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R'},
};
```
> 11. Write a program fragment that declares an 8x8 `char` array named `checker_board` and then uses a loop to store the following data into the array (one character per array element). > 11. Write a program fragment that declares an 8x8 `char` array named `checker_board` and then uses a loop to store the following data into the array (one character per array element).
```c
char checker_board[8][8];
for (int row = 0; row < 8; row++) {
for (int column = 0; column < 8; column++) {
if ((column + row) % 2 == 0) {
checker_board[row][column] = 'B';
} else {
checker_board[row][column] = 'R';
}
}
}
```