O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required