Tuesday, May 28, 2019

PHP While And Do-While Loop!!

PHP While And Do-While Loop!!



PHP while loop and do - while loop is used for execute the code of block until the condition is true.

In case of while loop number of iteration is not fixed.

While Loop 


While loop is used in unfixed number of iteration will executed.

Syntax :

Initialization
while ( condition )
{
     code of block
        increment or decrement of variable
}
  

Program :

PHP code for print simple numbers.



Output :

no is : 1 
no is : 2
no is : 3
no is : 4
no is : 5

Work :

Here, we take initial value of a = 1 then it check the while condition and print the code of while loop.after it increments value of a by 1.

Now, a = 1+1 = 2 same process will occur till the a is not became 6.

when value of a become 6 then the condition a<=5 is false and loop terminated.

Nested While Loop


Nested while loop means while loop in the while loop.

Inner loop is execute n number of times for every iteration of outer loop and code of inner loop is executed n times for every iteration of inner loop.

Syntax :

initialization ;
while ( condition )
{
     initialization ;
     while ( condition )
       {
            code of the loop
                increment/decrement
        }
       increment/decrement
}

Program :


Output :

*
**
***
****
*****

While Loop With Break Statement


When we want to know the number of iteration and want to perform simple program then we can use break statement.

when we not increment or decrement value on that case we have to use break statement.

Syntax :

while ( condition )
{
     code of loop
}
     break ;

Program :

check the given number is 10 or not.



Output :

a is 10

Work :

In this program we only check either given number is 10 or not.

we take number which is 10 then it print 10 otherwise not.

if we not use break statement then the loop is go in infinite loop and code print for infinite time.

so, for execute code only once then we have to use break keyword.

Do - While Loop


The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.

Program :


Output :

no is : 1 
no is : 2
no is : 3
no is : 4
no is : 5

In this article we will discuss about while and do-while loop in brief,for more interesting articles keep join us!!


Mesothelioma Survival Rates , Mesothelioma Attorneys California , Seattle Mesothelioma Lawyer , Mesothelioma Suit , Mesothelioma Claim , Wisconsin Mesothelioma Attorney , Mesothelioma Attorney illinois , Mesothelioma Trial Attorney ,Houston Mesothelioma Attorney , Mesothelioma Lawyer Dallas , New York Mesothelioma Law Firm,Mesothelioma Lawyer Asbestos Cancer Lawsuit , Mesothelioma Lawyers San Diego,Mesothelioma Litigation , Mesothelioma Attorney Assistance , Mesothelioma Lawyer Asbestos Cancer Lawsuit , Mesothelioma Lawyer Chicago , New York Mesothelioma Law Firm , 


Houston Mesothelioma Attorney , Mesothelioma Lawyer Dallas , Mesothelioma Care , Mesothelioma Trial Attorney , Mesothelioma Lawyer Texas , Lawsuit Mesothelioma  , Truck Accident Attorney Los Angeles ,Asbestos Exposure Lawyers  , Mesothelioma Cases  , Emergency Response Plan ppt , Mesothelioma Lawyers San Diego  , Asbestos Mesothelioma Lawsuit  , Tennessee Mesothelioma Lawyer , Meso Lawyer  , Mesothelioma Settlements Amounts  , Mesothelioma Law Firms , New Mexico Mesothelioma Lawyer , Accident Attorneys Orange County , Mesothelioma Lawsuit ,Personal Injury Accident Lawyer  , Purchase Structured Settlements  , Firm Law Mesothelioma , Car Accident Lawyers Los Angeles , Mesothelioma Attorneys , Structured Settlement Company  , Auto Accident Lawyer San Francisco  , Mesotheolima  , Los Angeles Motorcycle Accident Lawyer


Mesothelioma , Mesothelioma Lawyer Virginia , Seattle Mesothelioma Lawyer , Mesothelioma Attorney illinois , Mesothelioma Drug , Mesothelioma Attorney DirectoryMesothelioma Settlements , Mesothelioma Help  , Mesothelioma ct , Mesothelioma Attorney Florida , Washington Mesothelioma Attorney , Best Mesothelioma Lawyers , Diagnosed With Mesothelioma , Mesothelioma Settlement Amounts , Mesothelioma Personal Injury Lawyers , Mesothelioma Compensation , Attorney Lawyer Mesothelioma  ,Colorado Mesothelioma Lawyers,Mesothelioma Lawsuits , Mesothelioma Claims , Average Mesothelioma Settlement , Average Mesothelioma Settlement , Mesothelioma Law Suit , Alabama Mesothelioma Lawyer , alabama Mesothelioma Lawyer , utah mesothelioma lawyer , Dallas Mesothelioma Lawyer , Mesothelioma Attorney California , Mesothelioma Lawyer California ,Mesothelioma Survival Rates ,

Mesothelioma Attorneys California, Wisconsin Mesothelioma Attorney Mesotheliama , Mesothelioma Lawyer Virginia , Seattle Mesothelioma Lawyer , Mesothelioma Attorney illinois, Mesothelioma Trial Attorney Injury Lawyer Houston tx , Baltimore Mesothelioma Attorneys , Mesothelioma Care ,Mesothelioma Trial Attorney ,Mesothelioma Lawyer Texas , Mesothelioma Lawyer Dallas , Mesothelioma Care , Mesothelioma Trial Attorney , Mesothelioma Lawyer Texas , California Mesothelioma Attorney Philadelphia Mesothelioma Lawyer , Illinois Mesothelioma Lawyer , Mesothelioma Attorney , Mesothelioma Claims , Average Mesothelioma Settlement 
Integrated ehr , Mesothelioma Law Sui , Mesothelioma Lawyer California,Mesothelioma Attorney California ,Mesothelioma Law Suits ,Dallas Mesothelioma Attorneys ,Mesothelioma Drug ,Mesothelioma Attorney Directory