Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

int a = 9 + 3; int b = a % 7; int c = a - b; what is output of the foll…

Question

int a = 9 + 3; int b = a % 7; int c = a - b; what is output of the following code fragment? system.out.println(a + \ \ + b + \ \ + c); 12 1 11 12 5 7 12 4 3

Explanation:

Step1: Calculate value of a

$a = 9 + 3=12$

Step2: Calculate value of b

The % operator is the modulus operator. $b=a\%7 = 12\%7=5$ (since $12 = 1\times7+5$)

Step3: Calculate value of c

$c=a - b=12 - 5 = 7$

Answer:

12 5 7