Integer vs floating-point division — what does this code print?
Console.WriteLine(7 / 2);
Console.WriteLine(7.0 / 2);- A.3 3
- B.3.5 3.5
- C.4 3.5
- D.3 3.5
Answer: D
Prints 3 then 3.5. In 7 / 2 both operands are int, so C# does integer division and truncates the remainder → 3. In 7.0 / 2, 7.0 is a double, so the whole division is promoted to double → 3.5. The operand types decide the kind of division, not the type of the variable receiving the result.