0

Scope of formal parameters is function scope. Why?

Scope of formal parameters is function scope. Why?

16th Mar 2017, 3:18 AM
Srikanth Srinivasan
Srikanth Srinivasan - avatar
1 Réponse
+ 4
Formal parameters refer to the copy of the actual parameters( values passed to function during calling in main() ) created inside a function. These values are created when the function is called and all changes are done on them, leaving the original parameters unaffected. Thus, when the function ends execution, these variables are removed from memory, as they are similar to declaring variables inside a block. Thus, you cannot use them in the rest of your program.
16th Mar 2017, 8:42 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar