HOW THE OUTPUT IS 80…??¿‽
AND HOW IT WILL RUN 7TIMES?
I WANT DRY RUN... PLEASE
#java
Attachments:
Bphariharan:
wat is while(true then)
Answers
Answered by
1
when p = 200,
loop runs 1 time
if(p<100) is false
p = p-20 = 180
when p = 180,
loop runs 2 times
if(p<100) is false
p = p-20 = 160
when p = 160,
loop runs 3 times
if(p<100) is false
p = p-20 = 140
when p = 140,
loop runs 4 times
if(p<100) is false
p = p-20 = 120
when p = 120,
loop runs 5 times
if(p<100) is false
p = p-20 = 100
when p = 100,
loop runs 6 times
if(p<100) is false
p = p-20 = 80
when p = 80,
loop runs 7 times
if(p<100) is true, so the loop terminates...
so, the program runs 7 times... and the output is 80.
Similar questions