3) (5 + 10 + 15) * (1 / 3)\n4) x / y where int x = 10 and int y = 4.\n5) 10 / 4.0\n6) x / y where int x = 10…

3) (5 + 10 + 15) * (1 / 3)\n4) x / y where int x = 10 and int y = 4.\n5) 10 / 4.0\n6) x / y where int x = 10 and double y = 4.0.

3) (5 + 10 + 15) * (1 / 3)\n4) x / y where int x = 10 and int y = 4.\n5) 10 / 4.0\n6) x / y where int x = 10 and double y = 4.0.

Answer

Explanation:

Step1: Calculate sum in parentheses

$(5 + 10+15)\times(1/3)=(30)\times(1/3)$

Step2: Multiply

$30\times\frac{1}{3}=10$

Step3: For $x/y$ where $x = 10$ and $y = 4$ (integer division in programming - gives quotient)

$10\div4 = 2$ (integer division truncates the decimal part)

Step4: Calculate $10/4.0$ (floating - point division)

$10\div4.0 = 2.5$

Step5: For $x/y$ where $x = 10$ (int) and $y = 4.0$ (double), automatic type - conversion occurs and it's floating - point division

$10\div4.0 = 2.5$

Answer:

  1. 10
  2. 2
  3. 2.5
  4. 2.5