Tracing a Java While Loop
Consider the following code segment.
int val = 48;
int div = 6;
while ((val % 2 == 0) && div > 0)
{
if (val % div == 0)
{
System.out.print(val + " ");
}
val /= 2;
div--;
}
What is printed when the code segment is executed?
A
48 24 12 6
B
48 24 12 6 3
C
48 12 6 3 1
D
48 12 6
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE