Advertisements
Advertisements
Question
Analyze the following program segment and determine how many times the body of the loop will be executed (show the working).
x = 5; y = 50;
while (x <= y)
{
y = y / x;
System.out.println(y);
}
Answer in Brief
Solution
`50/5 = 10`
`10/5 = 2`
The loop is executed twice.
shaalaa.com
Is there an error in this question or solution?
Chapter 1.09: Iterative Constructs in Java - EXERCISES [Page 122]