about summary refs log tree commit diff stats
path: root/org/c/ex_05.org
diff options
context:
space:
mode:
authorelioat <hi@eli.li>2022-11-26 20:44:59 -0500
committerelioat <hi@eli.li>2022-11-26 20:44:59 -0500
commit2f4c578507a371caa7bba18d6d7104cb2d39182c (patch)
treeefe62851846a9a972741692c902010a5830ea1aa /org/c/ex_05.org
parentd9bf844148e0ca641c0894215c6afa0604229dc8 (diff)
downloadhard-way-2f4c578507a371caa7bba18d6d7104cb2d39182c.tar.gz
*
Diffstat (limited to 'org/c/ex_05.org')
-rw-r--r--org/c/ex_05.org80
1 files changed, 80 insertions, 0 deletions
diff --git a/org/c/ex_05.org b/org/c/ex_05.org
new file mode 100644
index 0000000..799712f
--- /dev/null
+++ b/org/c/ex_05.org
@@ -0,0 +1,80 @@
+* 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   |
+