Explain the difference between the local variable and global variable in C?
S.no | Local Variable | Global Variable |
---|---|---|
1. | Declared inside function | Declared outside function |
2. | Accessed only by statements that are inside a function where they are declared | Accessed by any statement throughout the program |
3. | Created when entering function block and gets destroyed when exits. | Stays in existence throughout the when the application is executing |
4. | It is stored on the stack. | Stored in a fixed location. |
BY Best Interview Question ON 06 Feb 2019