Advertisements
Advertisements
Question
Differentiate While and Do while loops.
Distinguish Between
Advertisements
Solution
| While loop | Do while loop |
| The while statement will execute a block of code if and as long as a test expression is true. | Do while loop always run the statement inside of the loop block at the first time execution. |
| If the test expression is true then the code block will be executed. After the code has executed the test expression will again be evaluated and the loop will continue until the test expression is found to be false. | Then it is checking the condition whether true or false. It executes the loop if the specified condition is true. |
|
|
shaalaa.com
Looping Structure
Is there an error in this question or solution?
APPEARS IN
RELATED QUESTIONS
Which loop evaluates condition expression as Boolean, if it is true, it executes statements and when it is false it will terminate?
What will be displayed in a browser when the following PHP code is executed:
<?php
for (Scounter = 20; $counter< 10;
$counter++)
{
echo “Welcome to Tamilnadu “;
}
echo “Counter is: Scounter”;
?>What will be the output of the following PHP code?
<?php
for ($x = 1; $x < 10;++$x)
{
print “*\t”;
}
?>What will be the output of the following PHP code?
<?php
for ($x = -1; $x < 10;--$x)
{
print $x;
}
?>Write Syntax of Do while loop in PHP.
Compare for loop and for each loop.
Write the purpose of Looping Structure in PHP.
Differentiate For each and While loop.
Discuss in detail about Foreach loop.
Explain working of loops in array.
