- 1

Will the for loop execute without initialization? Explain with examples.

4th Nov 2020, 4:23 PM
Syed Akash Ahmed
3 Respostas
+ 3
With "initalization" do you mean keeping the whole part in the parentheses empty: for (;;) {...} Or just the first statement: for (; i < 10; i++) {...} ? Anyways both would be valid to use, but... In the first example you would create an infinite loop, but you can fix this with a break statement. In the second example you still need to define variable i before the loop execution, for example: int i = 0; for (; i < 10; i++) {...} Otherwise an error will happen.
4th Nov 2020, 4:36 PM
Seb TheS
Seb TheS - avatar
+ 4
Please rather specify a relevant language name in tags above than writing 'please answer' ☝ You joined multiple courses, how to know which language you mean?
4th Nov 2020, 4:29 PM
Ipang
0
My question is for javascript language
10th Nov 2020, 4:48 PM
Syed Akash Ahmed