Difference No 1
for Loop
In for loop, initialization, condition and adjustment statements are all put together in one line which make loop easier to understand and implement.
while Loop
In the while loop, initialization is done prior to the beginning of the loop. Conditional statement is always put at the start of the loop. While adjustment can be either combined with condition or embedded into the body of the loop.
let we see with example:-
Difference No 2
for Loop
When using “continue;” statement in for loop, control transfers to adjustment statement
while Loop
In while loop control transfers to the condition statement.
let we see with example:-
0 comments:
Post a Comment