# Additional exercises

:::{exercise} Fizz buzz
:label: fizzbuzz
[Fizz buzz](https://en.wikipedia.org/wiki/Fizz_buzz) is a group game for children to teach them about division. If a number is divisible by three, you must say *Fizz*; if by five, *Buzz*; if by both *Fizz buzz*. For example a typical round looks like this:
> 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16 ...

Write a program that outputs the Fizz buzz sequence for numbers less than **40**. You can use colors to make the Fizz buzz numbers easier to notice:

```{literalinclude} code/fizzbuzz.txt
:language: text
```
:::

:::{exercise} Is there a bug? (2)
:label: is-there-a-bug2
Analyze the following code snippets. Is there a bug in each code? If yes, where?

Should loop over the characters of a word:
```c
#define WORD_LEN 40
char word[WORD_LEN];

for (size_t i = 1; i <= WORD_LEN; i++)
  if (word[i] == 'x')
// ...
```

Should replace `a` with `A` in the input word.
```c
for (size_t i = 0; i < sizeof(word); ++i)
    if (word[i] == "a")
        word[i] = "A";
```
:::


:::{exercise} How to debug
The following program should output `a`, but it does not. How would you debug it?
```{literalinclude} code/letter-with-highest-occurrence-buggy.c
:language: c
```
Output
```{literalinclude} code/letter-with-highest-occurrence-buggy.txt
:language: text
```
:::