Multiple choice technology programming languages

What does the following code snippet do: for(;;) ;

  1. The snippet is illegal

  2. It loops forever

  3. It is ignored by compiler, but it is not illegal

  4. None of the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The syntax for(;;) ; is a valid C/C++ statement. The empty conditions in the for loop default to true, and the trailing semicolon represents an empty loop body, causing the program to loop infinitely.