|
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 1h - Program Control : Do While Loops |
|
Do While Loops
A do while loop
is a while loop
where the condition is evaluated at the end so the statements
in the body are executed at least once. The do
while loop is constructed as
follows;
do
{
BODY
} while( CONDITION );
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 and 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;
do
{
x_array[x]
= 0;
x++;
} while( x<MAX_X ); |
int x;
int y;
int z;
x = 1;
y = 0;
do
{
if( z
& x) == x )
{
y++;
}
x
<<= 1;
} while( x!=0 ); |
|
 |
|