CBSE Class 12 Computer Science Question 3 of 101

Functions — Question 3

Back to all questions
3
Question

Question 3

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.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. 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.