August 2001
Beginner
482 pages
10h 52m
English
Normally, your program flows along line by line in the order that it appears in your source code. The if statement enables you to test for a condition (such as whether two variables are equal) and branch to different parts of your code depending on the result.
The simplest form of an if statement is this:
if (expression)
statement;
The expression in the parentheses can be any expression at all, but it usually contains one of the relational expressions. If the expression has the value zero, it is considered false, and the statement is skipped. If it has any nonzero value, it is considered true, and the statement is executed. Look at this example:
if (bigNumber > smallNumber)
bigNumber = smallNumber;
This code compares bigNumber ...
Read now
Unlock full access