When performing integer division in Java (/ with integer operands), the result is an integer, and any remainder is truncated. In this case, 20 / 4 equals 5.
public class IntegerDivisionExample {
public static void main(String[] args) {
// Define the values of p and q
int p = 20;
int q = 4;
// Perform integer division (p / q)
int result = p / q;
// Display the result
System.out.println("Result of p / q using integer division: " + result);
}
}
When you run this program, it will output:
Result of p / q using integer division: 5
This is because integer division in Java truncates the fractional part and returns the quotient as an integer. In this case, 20 / 4
results in 5
.