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 ...

Get C Programming: Visual Quickstart Guide 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.