+ 5

Someone please explain me while loops

I am not getting while loops

16th Apr 2019, 3:13 AM
Uday bhanu pratap singh
Uday bhanu pratap singh - avatar
7 ответов
+ 11
The while loop executes a block of code as long as the specified condition is true. $i = 1; while ($i < 5) { echo " $i <br />"; $i++; } Output will be: 1 2 3 4
28th Apr 2019, 7:21 PM
Spl
Spl - avatar
+ 5
While mood < 10: eat('cookie') #so until my mood is higher than 9, I'll eat cookies. If a cookie doesn't raise my mood, welp, looks like I'm gonna get fat eating cookies forever.
16th Apr 2019, 8:50 AM
Ahri Fox
Ahri Fox - avatar
+ 1
in While loop always the condition is checked if it is true then statement inside while loop is excuted this process repeated until the while condition become false
18th Apr 2019, 3:47 AM
Shivshankar Kumar
0
The statement repeats untill the condition become false Python i= 5 While i > 0: Print("i") i = i - 1
18th Apr 2019, 9:37 PM
seokamela ntjobokoane
seokamela ntjobokoane - avatar
0
There is always a condition in the while loop. 1. Check the condition 2. If its true the code inside the loop is executed. 3. Then again the condition is checked. 4. If its true, then again the code inside the loop is executed. 5. This above steps are continued till the condition is false. //Example for while loop in c++ to get the addition of all the integers from 1 to 5 int k = 1, total = 0; While (k <= 5) { total = total + k; //add k and total k++; // increments the value of k by 1 } cout<< " The total = " << total; //Output will be " The total = 15 " In this above code the value of k is increased by one till the condition of while loop become false. ( till the value of k is less than or equal to 5)
15th May 2019, 6:28 AM
Gothama Rajawasam
Gothama Rajawasam - avatar