This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
bok:sw:cpp:main [2021/06/21 12:06] anwlur [if ... else] added for |
bok:sw:cpp:main [2021/08/12 01:27] anwlur [if ... else] |
||
---|---|---|---|
Line 59: | Line 59: | ||
</code> | </code> | ||
+ | A shorthand is available for simple if...else statements | ||
+ | <code cpp> | ||
+ | variable = (condition) ? trueStatement : falseStatement; | ||
+ | </code> | ||
+ | |||
+ | E.g. | ||
+ | <code cpp> | ||
+ | variable = ( today == birthday ) ? "Happy Birthday" : "Good day!"; | ||
+ | </code> | ||
==== for ==== | ==== for ==== | ||
<code cpp> | <code cpp> | ||
Line 70: | Line 79: | ||
|| // logical OR | || // logical OR | ||
! // logical NOT | ! // logical NOT | ||
+ | | ||
+ | ==== Compound Operators ==== | ||
+ | ^= // compound bitwise XOR | ||
+ | += // compound addition | ||
+ | -= // compound substraction | ||
====== C++ for Arduino ====== | ====== C++ for Arduino ====== | ||