English

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); } - Computer Applications

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]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.09 Iterative Constructs in Java
EXERCISES | Q III. 2. | Page 122
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×