Question 77

Computer Awareness Data Structure Medium

What is the scope of the variable declared in the user-defined function?

(A) in whole program
(B) only inside the } block
(C) Both 1 and 2
(D) None of these
View Dynamic Solution & Explanation
Correct Solution: Option B

Step-by-step Solution:

In programming, the scope of a variable determines where in the program that variable can be accessed. When a variable is declared in a user-defined function, its scope is local to that function. This means: \[\] The variable is only accessible inside the function where it is defined. \[\] It is not accessible in the rest of the program or in other functions. The scope of the variable declared in the user-defined function is: only inside the block Final Remarks The local scope of a variable ensures that it can only be accessed and manipulated within the user-defined function in which it is declared. \[\] Correct Answer: (b)