Register|Login

Have a question? Click here to ask the community.

Quiz 16 – Do While Loop

| In: PHP Quizzes | 15,854 views

*You are currently not logged in and your quiz score will not be recorded. Please login or register if you would like to submit your quiz score.

Directions: Answer all questions. Any questions skipped will be scored as wrong answers. Good Luck! :)

1. A do while loop will execute a segment of code at least one time?

True
False

2. A do while loop will check the while condition before executing the segment of code between the curly braces?

True
False

3. Is the following a correct example for a PHP do while loop:

<?php
   $counter = 1;
   do while ($counter < 5);{
       $counter++;
   } 
   echo "Counter is: $counter";
?>

Yes
No

4. What will be displayed in a browser when the following PHP code is executed:

<?php
   $counter = 1;
   do while ($counter < 5);{
       $counter++;
   } 
   echo "Counter is: $counter";
?>

Counter is: 4
Counter is: 5
Counter is: 2
None of the above

5. What will be displayed in a browser when the following PHP code is executed:

<?php
   $counter = 1;
   do {
       $counter++;
   } while ($counter < 0); 
   echo "Counter is: $counter";
?>

Counter is: 4
Counter is: 5
Counter is: 2
None of the above

Comment Form

You must be logged in to post a comment.

Users Online

Users Online: 5 Users

Most Users Ever Online: 91

Quiz Scores

Advertisments