do while loop คำสั่งวนลูป do while ทำอย่างน้อย1ครั้ง
4/2/2561 SONGCHAI
PRAPATRUNGSEE
do while loop คำสั่งวนลูป do while ทำอย่างน้อย1ครั้ง
do...While
[Control Structure]
Description
The do…while loop works in the
same manner as the while loop, with the exception that the condition is tested
at the end of the loop, so the do loop will always run at least once.
Syntax
do
{
// statement(s)
} while (condition);
The condition is a boolean
expression that evaluates to true or false.
do statements; while (boolean
expressions);
Example
do
x = x+1 ;
while (x < 5) ;
////////////////////////////////////////////////////////////////
/* 4/2/2561
do while loop
by SOM MCU */
#include <REGX51.H> //REGISTER
MCU
void main (void)
{
char
x = 0 ;
do
{
x = x+1 ;
} while (x < 5) ;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น