Chapter 4. Control Structures
While the examples to this point have used variables, performed calculations, and reported on results, they still lack the dynamic nature of true programming. One of the key ingredients in real applications is the flexibility brought about by using control structures: constructs such as conditionals and loops.
The most common control structure is the if conditional and its kin: if-else, if-elseif, if-elseif-else, et al. This chapter covers if conditionals first; during this discussion you'll also see other operators commonly used in C (you've already come across the arithmetic and assignment operators). Next, you'll use two other conditionals, each with a unique syntax and usage: the ternary operator and the switch ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access