FuzzDuck
FuzzDuck
While
FuzzDuck
While

While

Setting a code to be run repeatedly, until a condition is met.

The while loop is a loop continues to run, as long as a specific condition is met. The condition can be an int counting up, ending the loop, when the int matches the required condition.

Code Example - While iteration
// --- Declaring starting point of the program run with "main" method --- //
public static void Main(string[] args){

 // --- Declaring int "number" to iterate through --- //
 int number = 1;

 // --- Iterating through "number" 5 as long as it is lower than 5 --- //
 while (number < 5) {
  Console.WriteLine("Running for the " + number + ". time");
  number++;
 }

 // --- Invoking 'ReadKey()' to make time to read the output --- //
 Console.ReadKey();

}
// --- Declaring starting point of the program run with "main" method --- //
public static void main(String[] args) {

 // --- Declaring int "number" to iterate through --- //
 int number = 1;

 // --- Iterating through "number" 5 as long as it is lower than 5 --- //
 while (number < 5) {
  System.out.println("Running for the " + number + ". time");
  number++;
 }

}
// --- Declaring int "number" to iterate through --- //
$number = 1;

 // --- Iterating through "number" 5 as long as it is lower than 5 --- //
while ($number < 5) {
 echo "Running for the " . $number . ". time <br>";
 $number++;

}

The above code will generate the following outcome

Running for the 1. time
Running for the 2. time
Running for the 3. time
Running for the 4. time