While loop:-
While Loop मे सबसे पहले Condition Check की जाती है अगर Condition True हो तभी While Loop के Inside Statements को Execute किया जाता है। While Loop के Inside Statements को Execute करने के बाद दोबारा से Condition को Check की जाती है अगर इस बार भी Condition True होती है तो फिर से While Loop के Inside Statements को Execute किया जाता है और यह Process तब तक चलता रहता है जब तक की Condition False ना हो जाये। जब condition false हो जाती तब execution stop हो जाता है
Note:- अगर Condition पहली बार में ही False हो जाये तब While Loop के Inside Statements को बिना Execute किये ही While Loop को Terminate कर दिया जाता है। इस लूप को Entry Controlled Loop भी कहा जाता है।
Syntax:-
<script>
while (condition)
{
code to be executed
}
</script>
Questions:- 1. Wap to print 1 to 10 numbers
2. Wap to print 25 to 1 numbers.
3. Wap to print table of user choice.
While loop:-
First of all the condition is checked in the while loop. If the condition is true then only the statements inside the while loop are executed. After executing the inside statements of the while loop, the condition is checked again. If this time also the condition is true then again the inside statements of the while loop are executed and this process continues until The condition should not become False. When the condition becomes false then the execution stops.
Note:- If the condition becomes False in the first instance, then the While Loop is terminated without executing the statements inside the While Loop. This loop is also called Entry Controlled Loop.
Syntax:-
<script>
while (condition)
{
code to be executed
}
</script>
Questions:- 1. Wap to print 1 to 10 numbers
2. Wap to print 25 to 1 numbers.
3. Wap to print table of user choice.