216k views
2 votes
A variable declared within the body of a loop does not retain its value from one loop iteration to the next.

True
False

User DitherSky
by
7.6k points

1 Answer

2 votes

Final answer:

A variable declared within the body of a loop does not retain its value from one iteration to the next; this statement is true as the variable is destroyed after each iteration.

Step-by-step explanation:

A variable declared within the body of a loop does not retain its value from one loop iteration to the next. This statement is True. In most programming languages, when you declare a variable inside a loop, its scope is limited to that loop iteration. As soon as the iteration is completed, the variable is destroyed and a new instance is created for the next iteration. This means that any value assigned to it during an iteration will not be retained in the next iteration.

User CommonKnowledge
by
7.4k points