Computer Science, asked by Jisu1361, 1 year ago

Will a for loop execute without initialization? Explain with suitable example.

Answers

Answered by KartikSharma13
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 dcdcsdn
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