O'Reilly logo

C Programming Absolute Beginner’s Guide, Third Edition by Dean Miller, Greg Perry

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

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

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