QUESTION IMAGE
Question
consider the following arithmetic expressions. int a = 11; int b = 3; a = a % b; b -= (a + 1); which of the following statements is true? a = 2 and b = 0 a = 3 and b = -1 a = 3 and b = 1
Step1: Calculate a % b
The % operator is the modulus operator which gives the remainder. Given $a = 11$ and $b = 3$, $11\bmod3=2$, so $a = 2$.
Step2: Calculate b -=(a + 1)
First, find $a + 1$, since $a = 2$, then $a+1=3$. Then, $b-=3$ means $b=b - 3$. Given $b = 3$ initially, $b=3 - 3=0$.
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 = 2 and b = 0