วันอาทิตย์ที่ 28 มกราคม พ.ศ. 2561

while Condition boolean expression true false คำสั่งวนลูปwhile จริงทำเท็จไม่ทำ




27/1/2561 SONGCHAI PRAPATRUNGSEE
while Condition boolean expression true false คำสั่งวนลูปwhile จริงทำเท็จไม่ทำ

while
[Control Structure]
Description
A while loop will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit. This could be in your code, such as an incremented variable, or an external condition, such as testing a sensor.

Syntax
while(condition)
{
  statement(s)
}
The condition is a boolean expression that evaluates to true or false.

Example Code
var = 0;
while(var < 5){
  // do something repetitive 5 times
  var++;
}
/////////////////////////////////////////////////////////////////////
/* 27/1/2561
while condition
by SOM MCU */

#include <REGX51.H>//REGISTER MCU

void main (void)
{
        char var = 0;
while(1)
{
       
while(var < 5)
{
  var++;
}
  var--;
}

}

ไม่มีความคิดเห็น: