Can a for statement loop indefinitely

Yes, a for statement can loop indefinitely. For example, consider the following:for(;;) ;

Showing Answers 1 - 12 of 12 Answers

angelina

  • Apr 18th, 2007
 


Yes, the for loop can run indefinately by doing this

for(int i=0;;)
{

}

Note: for loop must have at least initialisation step. so the above example for(;;) would not work and will give the compilation error

RKalaa

  • Apr 24th, 2007
 

The for loop will be working fine even without the initialization.Hence for(;;) will create a indefinite loop.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions