vault backup: 2024-10-08 21:20:19
This commit is contained in:
parent
75f65b24bb
commit
1622311f8f
@ -5,14 +5,28 @@ 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`.
|
||||
|
||||
> 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:
|
||||
```
|
||||
```c
|
||||
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.
|
||||
|
||||
```c
|
||||
const int segments[10][7] = {
|
||||
{1, 1, 1, 1, 1, 1, 0}, // 0
|
||||
{0, 1, 1, 0, 0, 0, 0}, // 1
|
||||
{}
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
>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]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user