QUESTION IMAGE
Question
consider the following arithmetic expressions. int a = 3; int b = 11; a = a % b; b += (a + 1); which of the following statements is true? a = 3 and b = 12 a = 3 and b = 15 a = 0 and b = 12
Step1: Calculate a % b
The '%' is the modulus operator. Given $a = 3$ and $b=11$, $a=a\%b$ means $a = 3\bmod{11}$. Since $3<11$, $a = 3$.
Step2: Calculate b + (a + 1)
We know $a = 3$, so $a + 1=4$. Then $b+= (a + 1)$ means $b=b+(a + 1)$. Substituting $b = 11$ and $a + 1=4$, we get $b=11 + 4=15$.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
a = 3 and b = 15