What happens to a local variable when the function in which it is defined finishes executing?

  • It becomes a global variable
  • It remains in memory
  • It's accessible from other functions
  • It's automatically freed
When a function finishes executing, the local variables defined inside it are automatically freed, and their memory is reclaimed. They do not persist after the function call.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *