This may be a stupid question, but how does the efficiency of a while loop compare to that of a for loop? I\'ve always been taught that if you can use a for loop,
Think of the main difference as style: with a for loop, you don't have to go looking for the initial value, threshold, and increment.
for
It's also a lot easier to make an infinite loop out of a while because you forgot to increment.
while