Sunday, 10 January 2021

What is While Loop? Example of While Loop in Java Script

 WHILE LOOP

 - A while loop in C programming repeatedly executes a target statement as long as a given condition is true.

 - The condition may be any expression, and true is any nonzero value. The loop iterates while the condition is true.

______________________________________

Syntax of While Loop:

    var initialization;

    while(condtion)

    {

        Statement

        increment/ decrement

    }

_______________________________________

Example of While Loop:

<script type="text/javascript" language="javascript">

//while loop

i=0;

b=0;

while (i<5)

{

  document.write("The number is " + i)

  document.write("<br />");

while(b<=3)

{

alert(b);

b++;

}

        i++;

}

</script>

_______________________________________

learn All Programming and Scripting languages with youtube.com/avadhtutor




    

No comments:

Post a Comment