11. The Fork in the Road—Testing Data to Pick a Path

In This Chapter

Testing data

Using if

Using else

C provides an extremely useful statement called if. if lets your programs make decisions and execute certain statements based on the results of those decisions. By testing contents of variables, your programs can produce different output, given different input.

This chapter also describes relational operators. Combined with if, relational operators make C a powerful data-processing language. Computers would really be boring if they couldn’t test data; they would be little more than calculators if they had no capability to decide courses of action based on data.

Testing Data

The C if statement works just like it does in spoken language: ...

Get C Programming Absolute Beginner’s Guide, Third 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.