Why we use while loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why we use while loop?

9th Nov 2019, 7:23 AM
Nitesh Gairola
Nitesh Gairola - avatar
4 Answers
+ 10
Nitesh Gairola you have everything explained in the tutorial. Please, Read the COMMENTS in the lessons as you can find great examples and explanations.
9th Nov 2019, 10:06 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
When you want to repeat code as long as a condition is satisfied.
9th Nov 2019, 8:47 AM
Sonic
Sonic - avatar
+ 6
When we want to execute a block of code many times but we do not know the exact number of times the loop will execute, in such case we use while loop. While loop will execute till the condition specified is true, as soon as the condition becomes false the loop gets terminated.
9th Nov 2019, 7:30 AM
Chetali Shah
Chetali Shah - avatar
+ 5
The while loop is used to reach an answer to which the number of iterations are not known before hand.
9th Nov 2019, 7:30 AM
Avinesh
Avinesh - avatar