In this Video :
Imagine CSK is at a score of one ninety and needs just six more runs to win. Our target is one ninety-six. What better way to relate this to programming than by using a while loop?
We use a while loop because we don’t know how many deliveries it will take to reach the winning score. The condition is open-ended the game continues until the target is reached.
Here's the logic:
Start with the score at one ninety.
On every ball, the score increases.
Keep looping until the score hits one ninety-six.
The loop breaks once the condition is no longer true : CSK wins!
We choose a while loop instead of a for loop because we don’t have a fixed number of iterations. It’s dynamic : just like the real match situation!
This is how real-life scenarios can make programming fun and easy to understand. Share this with someone who loves both cricket and coding! 😎
To know more watch the full video & Stay tuned here for the tech insights
Follow us on Instagram : www.instagram.com/errormakesclever/?hl=en
Follow us on linkedin : www.linkedin.com/company/errormakesclever
Follow us on facebook : www.facebook.com/errormakesclever/
Subscribe : / @errormakesclever
Website: www.errormakesclever.com/
#CodingConcepts #WhileLoop #csk #programmingmadeeasy #errormakesclever
コメント