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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Static variables and Register variables in C
- Static Variables in C
- Initialization of static variables in C
- Initialization of global and static variables in C
- What are the default values of static variables in C?
- Internal static variable vs. External static variable with Examples in C
- Static functions in C
- Can static functions be virtual in C++?
- Static data members in C++
- C++ | Static Keyword | Question 6
- C++ | Static Keyword | Question 5
- When are static objects destroyed?
- C++ | Static Keyword | Question 1
- C++ | Static Keyword | Question 2
- C++ | Static Keyword | Question 4
- Difference between Static and Shared libraries
- “static const” vs “#define” vs “enum”
- Variables in C++
- Count the number of objects using Static member function
- Variables and Keywords in C
Improved By : InathiSirayi