* Exercise 5 ** Operators *** arithmetic operators | operator | description | |----------+-------------| | + | add | | - | subtract | | * | multiply | | / | divide | | % | modulus | | ++ | increment | | -- | decrement | *** relational operators | operator | description | |----------+--------------------| | == | equal | | != | not equal | | > | greater than | | < | less than | | >= | greater than equal | | <= | less than equal | *** logical operators Logical operators perform logic tests. They weirdest one is the [[https:www.freecodecamp.org/news/c-ternary-operator/][ternary operator]]. The ternary operator is sort of like a different way to write an if/else statement. #+BEGIN_SRC plaintext condition ? value_if_true : value_if_false #+END_SRC | operator | description | |----------+-----------------| | && | logical and | | || | logical or | | ! | logical not | | ? : | logical ternary | *** bitwise operators Bitwise operators are the weirdos, and the ones you don't often encounter in other languages...or like, in JavaScript, I guess. They alter bits directly. They are useful when working in low-level systems. | operator | description | |----------+--------------------------| | & | bitwise and | | | | bitwise or | | ^ | bitwise xor | | ~ | bitwise one's complement | | << | bitwise shift left | | >> | bitwise shift right | *** assignment operators Assignment operators assign expressions to variables. | operator | description | |----------+--------------------------| | = | assign equal | | += | assign plus-equal | | -= | assign minus-equal | | *= | assign multiply-equal | | /= | assign divide-equal | | %= | assign modulus-equal | | <<= | assign shift-left-equal | | >>= | assign shift-right-equal | | &= | assign and-equal | | ^= | assign xor-equal | | | | assign or-equal | *** data operators These deal with aspects of pointers, member access and various other data structures in C. | operator | description | |----------+-----------------------| | sizeof() | get the size of | | [] | array subscript | | & | the address of | | * | the value of | | -> | structure dereference | | . | structure reference |