87.9k views
5 votes
Why do local variables lose their values between calls to the function in which they are

defined?

User Sigcont
by
5.5k points

1 Answer

3 votes

Answer:

Variables which are declared within a function are called Local variables.They are named local because they are used locally only means they cannot be used outside the function in which they are declared.These local variables exist in the memory till the function execution starts and are deleted when the execution of function ends.Hence they lose their value between calls to the function in which they are declared.

User Amranur Rahman
by
5.1k points