|
Ordering Information |
|
.: Ordering using our PayPal powered shopping cart (PayPal
account not required).
|
CAN232 : $79 |
|
|
|
|
|
CANUSB : $89 |
|
|
|
|
|
I2C232 : $79 |
|
|
|
|
|
I2CUSB : $89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Click here to View Cart and check out.
|
|
|
|
|
 |
 |
 |
Chapter 1i - Program Control : If Statements |
|
If Statements
An if
statement performs a check and controls program execution
based on that check. The if
statement is constructed as follows;
if ( CONDITION )
{
BODY
}
else if( CONDITION )
{
BODY
}
else
{
BODY
}
The body is executed only if the if the condition is True.
Here are 2 examples.
|
Example #1 |
Example #2 |
|
#define DIFF 0
#define ADD 1
int x;
int y, z;
if( x == ADD)
{
y = y
+ z;
}
else if( x == DIFF)
{
y = y
- z;
}
else
{
} |
int x;
int y;
int z;
if( x == y) /* note that only 1 statement follows */
z =
x;
if( x )
y =
x;
if( x > 0) /* better example of the previous one
*/
{
y =
x;
} |
|
 |
|