In C, variables are always statically (or lexically) scoped i.e., binding of a variable can be determined by program text and is independent of the run-time function call stack.
For example, output for the below program is 0, i.e., the value returned by f() is not dependent on who is calling it. f() always returns the value of global variable x.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Difference between Static variables and Register variables in C
- Static Variables in C
- Initialization of static variables in C
- What are the default values of static variables in C?
- Initialization of global and static variables in C
- Internal static variable vs. External static variable with Examples in C
- Static functions in C
- Static data members in C++
- When are static objects destroyed?
- C++ | Static Keyword | Question 3
- C++ | Static Keyword | Question 2
- Can static functions be virtual in C++?
- C++ | Static Keyword | Question 1
- C++ | Static Keyword | Question 5
- C++ | Static Keyword | Question 6
- C++ | Static Keyword | Question 4
- “static const” vs “#define” vs “enum”
- Difference between Static and Shared libraries
- Variables in C++
- Variables and Keywords in C
Improved By : InathiSirayi