223k views
7 votes
What is the value of numC at the end of this loop?

numC = 12

while numC > 3:

numC = numC / 2


numC =

User Spedwards
by
4.3k points

1 Answer

10 votes

Answer: 3

Step-by-step explanation:

What is the value of numC at the end of this loop?

numC = 12

while numC > 3:

numC = numC / 2

numC =

The initial numC value = 12

Condition : while numC is greater than 3 ; 12 > 3 (condition met)

The expression numC / 2 is evaluated

numC / 2 = 12 / 2 = 6

numC then becomes 6 ;

Condition : while numC is greater than 3 ; 6 > 3 (condition met)

numC / 2 = 6 /2 = 3

numC = 3

Condition : while numC is greater than 3 ; 3 > 3 (condition not met)

Loop terminates

numC = 3

User Patryk Kubiak
by
4.5k points