- Home
- Class - 12 CBSE Computer Science — Assertion Reason Type Questions
Assertion (A): Local Variables are
Class - 12 CBSE Computer Science — Assertion Reason Type Questions
Assertion (A): Local Variables are accessible only within a function or block in which they are declared.
Reasoning (R): Global variables are accessible in the whole program.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Answer
Both A and R are true but R is not the correct explanation of A.
Explanation
Local variables have a limited scope and are accessible only within the function or block where they are defined. On the other hand, global variables have a broader scope and can be accessed from any part of the program, including functions and blocks.