Appendix A. Leftovers: The top ten things (we didnât cover)
Even after all that, thereâs still a bit more.
There are just a few more things we think you need to know. We wouldnât feel right about ignoring them, even though they need only a brief mention, and we really wanted to give you a book youâd be able to lift without extensive training at the local gym. So before you put the book down, read through these tidbits.
#1. Operators
Weâve used a few operators in this book, like the basic
arithmetic operators +
, -
,
*
, and /
, but there are many other operators
available in C that can make your life easier.
Increments and decrements
An increment and a decrement increase and decrease a number by 1. Thatâs a very common operation in C code, particularly if you have a loop that increments a counter. The C language gives you four simple expressions that simplify increments and decrements:
Each of these expressions will change the value of i
. The position of the ++
and --
say whether or not to return the original value of i
or its new value. For example:
The ternary operator
What if you want one value if some condition is true, and a different value if itâs false?
if (x == 1) return ...
Get Head First C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.