-
What is the output of this program?
public class Modulus_Example
{
public static void main(String args[])
{
double p = 10.34;
int q = 20;
p = p % 15;
q = q % 20;
System.out.println(p + " " + q);
}
}
-
- 10 0.0
- 11 10.00
- 10.22 10
- 10.34 0
- 2 10.21
Correct Option: D
Modulus operator returns the remainder of a division operation on the operand. p = p % 15 returns 10.34 % 15 i:e 10.34 Similarly q = q % 20 returns 0.
output: 10.34 0