Quiz Question 1 of 5
Consider the code snippet that prints the value of n
and then decrements n
by 1 in each iteration. If the loop condition is mistakenly written as while n >= 0:
, what logical issue will arise, and how will it impact the final output?
Choose the correct answer below:
-
A
The loop will skip the last iteration when
n
is0
, resulting in an incorrect output. -
B
The loop will print negative numbers until a stack overflow occurs.
-
C
The loop will run infinitely and never terminate.
-
D
The loop will terminate once
n
becomes-1
, and the final output will be "value ofn
after the loop is-1
".