Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

what is the output of this code fragment? int a = 5 - 1; int b = 2 * 3;…

Question

what is the output of this code fragment?
int a = 5 - 1;
int b = 2 * 3;
int c = a - b;
system.out.print(a + \ \ + b + \ \ + c);

Explanation:

Step1: Calculate value of a

$a = 5 - 1 = 4$

Step2: Calculate value of b

$b = 2 \times 3 = 6$

Step3: Calculate value of c

$c = a - b = 4 - 6 = -2$

Step4: Output a, b, c

Print $a + " " + b + " " + c$ → 4 6 -2

Answer:

4 6 -2