Multiple choice technology architecture

Consider the following program: void main () { foo (); } void foo () { for ( ; ; ) ; } The code will complete after how many iterations?

  1. 10

  2. 20

  3. Upon integer overflow

  4. Will never complete

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

The code for(;;) is an infinite loop in C and C-like languages. The semicolons indicate an empty condition, which evaluates to true, creating a loop that never terminates. The function foo() contains this infinite loop and never returns. Therefore main() never completes after calling foo(). The program will run forever unless externally terminated. Option D is correct - the code will never complete.