Multiple choice

int i = 4; int x = 6; double z; z = x / i; printf(z=%.2fn, z);

What will print when the sample code above is executed?

  1. z = 0.00

  2. z = 1.00

  3. z = 1.50

  4. z = 2.00

  5. z = NULL

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

When dividing two integers (6/4), C performs integer division, not floating-point division. The result is 1 (the decimal part is truncated), which is then stored in double variable z and printed as 1.00. To get 1.50, you would need to cast one operand to double first.