67.2k views
0 votes
The value in a ________ variable persists between function calls.

A) dynamic
B) local
C) counter
D) static local

1 Answer

2 votes

Final answer:

The value in a static local variable persists between function calls, allowing a function to remember information between calls without using global variables.

Step-by-step explanation:

The value in a static local variable persists between function calls. Unlike dynamic, local, or counter variables that reset every time a function is exited, a static local variable will maintain its value even after the function has finished executing. When the function is called again, the static local variable will still hold the value it was last assigned.

This is useful in situations where a function needs to remember the state of a particular piece of information between calls, without using global variables. For example, if you want to count how many times a function has been called, a static local counter variable can be used to accumulate the count over multiple calls.

User Caspar Harmer
by
7.9k points