+ 7
Loop battle:which loop do you prefer most 'for' or 'while'??? And your opinion....
10 Answers
+ 5
while loop is the best
+ 5
actually they both can be used to perform the very same task,
but for a learner
(it was my experience when i started learning loops)
it was easy to understand while loop and thats the only advantage while loop has
+ 5
yeah once you mastered loop its great to use for loop to shorten your work
+ 4
i think its for loop...
+ 4
ooohhh...
i understand...
+ 4
The answer is --> I'll use whichever loop I'll find most suitable in my current problem.
That's the whole game, isn't it ?
+ 3
thanks all for your advices..đđ
+ 2
Typically, you would want to use a for loop when you have a determinate number of iterations and a while loop when you have an indeterminate number of iterations.
For example, if youâre iterating through an array, you should usually know how many times youâll loop. If youâre reading through a file, you donât necessarily know when the reading should end - you would stop at the point of reaching EOF.
+ 1
hi,
for and while loops are the most generous loops.
for statements takes the shorter path
while, while loops takes the longer road to comply.
so , my friends regards to the program we are creating
shorter roads are more interesting than longer one.
! HAPPY CODDING !
+ 1
If I have to drive my vehicle for 5kms ,I'll choose for loop
and if I have to drive my vehicle until I'm out of fuel, I'll use while loop..
hope you get that