Multiple choice technology programming languages

int i=5; if(i=4) { printf("A"); } else { printf("B"); }

  1. This code will hang

  2. This code will print B.

  3. This code will print A.

  4. Compilation Error

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

In the condition if(i=4), the assignment operator (=) is used instead of the equality operator (==). This assigns the integer 4 to i, and since 4 is non-zero, the condition evaluates to true, causing the code to print A.