int a=1000,b=10,c=1; do { a=a/b; c=c+1; } while(b<=a) System. out. println(" " +c) ; PREDICT THE OUTPUT
Answers
Answer:
4
Explanation:
Do loop is an exit controlled loop which means that the condition is checked after execution of the body of the loop once. Thus, on the first execution of the loop body, we get the value of a as 1000/10 which is 100. Then, the value of c is incremented by 1, which makes the value of c=2. Then, the condition is checked. As 10<=100, the loop body gets executed again. On the execution of the loop body, we get the value of a as 100/10 which is 10. Then, the value of c is incremented by 1, which makes the value of c=3. Then, the condition is checked. As 10<=10, the loop body gets executed again. On the execution of the loop body, we get the value of a as 10/10 which is 1. Then, the value of c is incremented by 1, which makes the value of c=4. Then, the condition is checked. As 10>1, the execution ends. The output is printed as 4.