|
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 1g - Program Control : While Loops |
|
While Loops
A while loop
is like a for loop
without the INITIALIZATION or ITERATION section and is
constructed as follows;
while( CONDITION )
{
BODY
}
The body is executed as long as the condition is True. Here
are 2 examples. In the first one, we are initializing the
variables in an array. In the second one, we are counting the
number of bits that are 1 in a variable.
|
Example #1 |
Example #2 |
|
#define MAX_X 10
int x;
int x_array[MAX_X];
x = 0;
while( x<MAX_X )
{
x_array[x]
= 0;
x++;
} |
int x;
int y;
int z;
x = 1;
y = 0;
while( x!=0 )
{
if( z
& x) == x )
{
y++;
}
x
<<= 1;
} |
|
 |
|