Ask Question

The scope of a variable declared inside of a function is:

a) Local - within that function

b) Within that file only

c) global

+3
Answers (1)
  1. 21 July, 10:38
    0
    The correct answer for the given question is option (a) i. e Local - within that function.

    Explanation:

    The variable which is declared inside any function are called as local variable The scope and lifetime of local variable is inside that block or function only.

    They cannot access outside the function.

    Following are the example of local variable

    #include / / header file

    void fun (); / / function prototype

    int main () / / main function

    {

    fun (); / /calling function

    print ("%d", t); / / it gives error because t is local variable cannot access in main function

    return 0;

    }

    void fun ()

    {

    int t=9; / / local variable

    printf ("t is local variable which value is:");

    printf ("%d", t);

    }

    As we seen that t cannot access outside the function. So correct answer is option (a)
Know the Answer?