Will a for loop execute without initialization? Explain with suitable example.
Answers
Answered by
21
loop is used for executing a block of statements repeatedly until a given ... Note: Even though we can skip initialization part but semicolon (;) before condition is must.
Answered by
38
no...a for loop cannot execute without initialization.
example....var number=1
for(number<=10;number++){
}
here..the loop will not get executed because the initialization statement is missing...
to wrtie the correct code....it is must to add the initalization statement..
the correct code for the example given above will be:
var number
for(number=1;number<=10;number++){
}
Similar questions
History,
7 months ago
English,
7 months ago
Computer Science,
7 months ago
Computer Science,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago