Multiple choice technology programming languages

How long does the following code run? for(int x=0; x=3; x++)

  1. Never

  2. Three times

  3. Forever

  4. Error

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

The loop condition x=3 uses the assignment operator = instead of the comparison operator ==. The assignment expression evaluates to 3, which is treated as a truthy value in C/C++. Because this condition is always true, the loop will execute infinitely (forever).