O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

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

The Basic if Statement

The premise behind decision making in programming is to allow conditional execution of a block of code. It is the equivalent of the programmer telling the computer “if <this> happens, I want you to do <that>.”

This is an A-B type statement. It conveys a binary choice: There is no alternative. Once the condition is met, the code block will be executed. No matter how complex the condition that you are evaluating is, the final result is true or false. This kind of decision-making mechanism is called an if statement.

The if statement is the basic form of decision making in C. It allows the programmer to mark a set of statements for conditional execution; they will be evaluated only if a specific condition evaluates to true. ...

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