Question: no hand written answers please. for loop VS while loop for loop and while loop are equivalent, just a different syntax for the same thing.
for loop VS while loop for loop and while loop are equivalent, just a different syntax for the same thing. You can emulate a for loop with a while loop in mostly any language, here is an example of that: code output while int i-0; loop while (i-3) System.out.println("i3 for or int i-0 loop i-3:i++) System.out.println("i3 One main difference is while loops are best suited when you do not know ahead of time the number of iterations that you need to do. When you know this before entering the loop you can use for loop. Can we emulate a for loop to a while loop? When it is best to do a while loop instead of for loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
