From 2f4c578507a371caa7bba18d6d7104cb2d39182c Mon Sep 17 00:00:00 2001 From: elioat Date: Sat, 26 Nov 2022 20:44:59 -0500 Subject: * --- org/c/ex_05.org | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 org/c/ex_05.org (limited to 'org/c/ex_05.org') 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 | + -- cgit 1.4.1-2-gfad0