83.1k views
5 votes
Ar count = 10;

while (count>0)
{

count = count -2;

}

What is the value of count after the code segment above is executed?

User Tim Raynor
by
7.3k points

1 Answer

7 votes

Answer:

The value of count after the code is executed is 0

Step-by-step explanation:

According to the code initially the value of count is 10

while (count>0)

{

count=count-2

}

means 10>0 condition is true

count=10-2=8

Again 8>0 condition of while loop is again true

now count becomes=6

This process repeated untill the condition of while loop is true

and at last count becomes 0 the condition is false (0>0) so count becomes 0 after the code segment is executed

User Kishan Viramgama
by
7.0k points