Scope and lifetime of a variable declared in a function exist till the function exists?

60. Scope and lifetime of a variable declared in a function exist till the function exists?

  1. True
  2. False

Answer: A) True

Explanation:

It is the portion of a program where a variable is recognized that is referred to as its scope. It is not possible to see the parameters and variables defined within a function from outside of the function. As a result, they are limited in their application. The lifetime of a variable is the period of time during which the variable is stored in the memory of the computer. The lifetime of variables contained within a function is equal to the length of time the function is in operation. When we return from the function, they are completely destroyed. As a result, a function does not retain the value of a variable from previous calls to the function.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.