NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
The if statement

The if statement evaluates a condition.

If the condition is true, it executes one statement (the consequence). The value of a condition is considered to be false only when it evaluates to zero. If it evaluates to any non-zero value, it is true. The syntax for an if statement is shown below.

if (condition) consequence

The condition of an if-statement must be enclosed in parentheses, as shown in the code sample below. The compound statement in the last example allows two statements to execute as a consequence of the condition being true.

if (x==1) y = 2;
if (x==1) { y = 1; z = 2; }