Thursday, February 3, 2011

While Loop and Do...While Loop

Assalamu'alaikum and selamat sejahtera

After For loops ,we will learn the While loop and Do..While loop.For those who already learned the C programming or other language programming might does not need explanation on this loops.For the beginner,just click here for more explanation.

oKEy,the concept of this loop is quite simple:


while (condition) {
code that to be executed if the condition is true
}


For example

$number = 1;
while ($number =< 10) {
print (" number = " . $number . "<BR>");
$number++;
}


and for Do....While loop:

do
statement
while (condition)


for example:

$number = 1;

do
{
print (" number = " . $number . "<BR>");
$number++;

}
while ($number =< 10);

Is quite simple ryte?why don't u try these loop on the previous exercise.

The Code for do...while loop:
<html>
<head>
<title>Do...While loop</title>

<?PHP
$number=1;

do
{

print (" number = " . $number . "<BR>");
$number++;

}
while ($number <= 10);
?>

</head>

<body>
</body>

<html>


N/NOTE:lalalala

No comments:

Post a Comment