Do While Loop
×
Home Courses Community Support
Do While Loop

Do While Loop is very similar to while loop. The difference is, it check the condition at the end of the block and while loop check the condition at the beginning of the block. It means do-while will execute the condition at least once, even the condition is true or false.

See below example-

<?php
$i = 1;
do {
    echo $i++;
} while ($i <= 5);
?>

Output:

12345

 

Let's check an example when the condition is not true. The code will run once-
 

<?php
$i = 1;
do {
    echo $i;
} while ($i < 1);
?>

Output:

1

 

 

← Preview

While Loop

Next →

For Loop

NOTES

Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.

Courses

  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App