Chapter 8

Decision Making

IN THIS CHAPTER

check Comparing conditions with if

check Using comparison operators

check Adding else to the decision

check Creating an if-else-if-else structure

check Making logical decisions

check Working with a switch-case structure

check Appreciating the ternary operator

Decision making is the part of programming that makes you think a computer is smart. It’s not, of course, but you can fool anyone by crafting your code to carry out directions based on certain conditions or comparisons. The process is easy to understand, but deriving that understanding from the weirdo way it looks in a C program is why this chapter is necessary.

What If?

All human drama is based on disobedience. No matter what the rules, no matter how strict the guidelines, some joker breaks free and the rest is an interesting ...

Get C Programming For Dummies, 2nd Edition 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.