Computer Science, asked by jinton, 11 months ago

will a for loop execute without initialization?

Answers

Answered by Leukonov
3
Yes. it will...But there are some conditions...

Eg: for(;;) --is called infinite loop and will cause a system error(it will execute and the screen will flicker) ; but with using suitable logic and operations... The infinte loop has big potential.

Eg2.
int sum=0,i=0;
for(;i<10;i++)
{sum=i+sum;}

Here there is no initialisation inside the loop But, the Forehanded initialisation will sustitute for the Initialisation inside the loop.

Eg3
int sum=0;
for(;i<10;i++)
{sum=sum+i;}

Here the loop will cause an error.
as the variable 'i' is not initialised anywhere in the prgrm... So The loop as well as the program won't execute.

Hope it Helps...
Regards,
Leukonov.
Similar questions