Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

int a = 19 - 17; int b = a * 5; int c = a % b; what is the output of th…

Question

int a = 19 - 17; int b = a * 5; int c = a % b; what is the output of the following code fragment? system.out.println(a + \ \ + b + \ \ + c); 2 10 2 2 10 5 2 10 0

Explanation:

Step1: Calculate value of a

$a = 19 - 17=2$

Step2: Calculate value of b

$b=a*5 = 2*5 = 10$

Step3: Calculate value of c

The % operator is the modulus operator, which gives the remainder of the division. So $c=a\%b=2\%10 = 2$

Answer:

2 10 2