# Strings, Boolean expressions, `auto`

(strings)=
## Strings

:::{literalinclude} ../code/strings.c
:language: c
:::
:::{literalinclude} ../code/strings.txt
:language: text
:::


:::{activity}
Peek into `string.h` in the standard library. Select function/s which can be useful for finding a string in an array of strings.

3 min
:::


## Boolean expressions

[The "questions" we had previously](if) are in fact Boolean expressions.

:::{wpd} Boolean expression
an expression that produces a Boolean value. Such a value is either true or false.
:::

### Examples

```c
// Simple boolean comparisons
bool isEqual = 5 == 5;            // true
bool isNotEqual = 5 != 5;         // false
bool isGreater = 10 > 5;          // true
bool isLess = 5 < 10;             // true
bool isGreaterThanEqual = 5 >= 5; // true
bool isLessThanEqual = 10 <= 5;   // false

// Combination operators
bool andCondition = 5 > 3 && 10 < 20; // true (both must be true)
bool orCondition = 5 > 10 || 3 < 4;   // true (enough if one is true)
bool notCondition = !(5 == 5);        // false (negation)

int main() {
  // Practical example: Check if a number is within a range
  auto number = 7;
  bool isInRange = number > 5 && number < 10; // true
}
```

We can use the Boolean expression on the right of the equal sign `=` in the `if` statement.

:::{activity}
:label: bool-expr-which-false
Which of the following are Boolean expressions *and* evaluate to `false`, assuming the following initialization code? The statements in the choices do not affect others.

```c
auto t = true;
auto f = false;
auto c = 3;
auto i = 9;
auto k = 11;
```
Choices:
1. `t == f`{l=c}
2. `t = f`{l=c}
3. `i >= c && k > i`{l=c}
4. `!t`{l=c}
5. `k != 11`{l=c}
6. `10 < c || c <= 20`{l=c}
:::

## Appendix

- [`auto` in C23](https://dev.to/pauljlucas/auto-in-c23-ij9)
- [`typeof` in C23](https://dev.to/pauljlucas/typeof-in-c23-55p2) ❎TODO