+ 2
The loop function
please is it necessary if i learn all the "for loop", "while loop" and "do while loop" ?
3 odpowiedzi
+ 7
A large part of programming is loops and conditionals. If you want to be a programmer, you need to know them.
+ 5
Yes, they are not very hard concepts to understand and each have a use. I highly recommend putting in the effort to understanding each.
+ 3
There are reasons for different type of loops cause you may need to solve problems with different approaches.
Example For :
You start from one point to one point by required steps
You climb stairs 2 by 2 till reaching 10th step
Example Do while;
Climb stairs till there is no steps left
Example While :
Climb steps till you die or you want to stop
Btw I am not kidding if you do not break it you will be in endless loop
Also one more important thing about these loops
-for checks condition at beginning and leave loop
-do / while at least run one time then check the condition and leave loop