PHP Programs

Program for while loop

In this program demonstrate use of while loop.  While Loops are used to execute statement repeatedly depending on condition

While loop are used to execute statements (block) of code a repeatedly until the condition gets satisfied

Program

<html>

<head>

<title> while...loop</title>

</head>

<body>

<?php

$i=0;   

$num=50;

while($i<10)

{

  $num--;

  $i++;

}

    echo"loop stopped at i=$i and num=$num";

 ?>

 </body>

 </html>

When Run The Program Following Output:

loop stopped at i=10 and num=40

Description

While loop is another loop that execute block of code if given condition is true.

 

Syntax of while

 

while (condition)

{

//block of code to be executed if condition true;

}

Releted Programs

© 2017 codewmAll rights reserved.