Is it this kind of thing:
for(;;) { statements; }
Or is it this:
for(initialisation;condition;updation) { }
I am looking for answers with references to a variety of sources.
An empty loop is a loop which has an empty body, e.g. for(int i = 0; i < 10; ++i) {} while(cin) {} (note that the second example here also happens to be endless)
An empty loop is a loop which does not have any updation or value of iteration. For example, for(int i = 1;;) (in Java) An empty loop is infinite.
An empty loop is a loop that doesn't contain any executable statement, whereas, an infinite loop is a loop that runs an infinite number of times. An empty loop contain only one empty statement. They are mostly used to produce time breaks. for(int a=0;a<10;a++); An infinite loop on the other hand continues forever.
We use pass statement to write empty loops. Pass is also used for empty control statement, function and classes.
Your first case (for with empty expressions) is an infinite loop and the second one (with empty body of the for statement) is an empty loop
In my environment it is like this:
for(;;) { statements; }
endless loop
for(initialisation;condition;updation) { }
empty loop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With