24sp ver.

Note: this is for the Spring 2024 iteration of CSE 121. Looking for a different quarter? Please visit https://courses.cs.washington.edu/courses/cse121/.

## Escape Sequences¶

Sequence | Description |
---|---|

`\t` | tab |

`\n` | new line |

`\"` | quotation mark |

`\\` | backslash |

## Data Types¶

Type | Description | Examples |
---|---|---|

`int` | integers, whole numbers | `42` , `-3` , `92851` |

`double` | decimal numbers | `3.14` , `2.0` |

`String` | text | `"Hello"` , `"CSE 121"` |

`boolean` | logical values | `true` , `false` |

## Expressions¶

- Precedence:
`()`

before`*`

`/`

`%`

before`+`

`-`

- with
`int`

,`/`

is integer division and`%`

is integer remainder - Strings can be concatenated with other values

## Arithmetic Operators¶

**(Compute a value using arithmetic operations)**

Operator | Meaning |
---|---|

`+` | addition |

`-` | subtraction, negation |

`*` | multiplication |

`/` | division |

`%` | remainder (“modulus”) |

## Relational Operators¶

Operator | Description |
---|---|

`<` | less than |

`<=` | less than or equal |

`>` | greater than |

`>=` | greater than or equal |

`==` | equal |

`!=` | not equal |

## Logical Operators¶

**(Evaluate expressions as true or false)**

Operator | Description |
---|---|

`&&` | and |

`||` | or |

`!` | not |

### Truth Table for `&&`

¶

Expression | Result |
---|---|

`true && true` | `true` |

`true && false` | `false` |

`false && true` | `false` |

`false && false` | `false` |

### Truth Table for `||`

¶

Expression | Result |
---|---|

`true || true` | `true` |

`true || false` | `true` |

`false || true` | `true` |

`false || false` | `false` |