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
- Internal static variable vs. External static variable with Examples in C
- What are the default values of static variables in C?
- Initialization of static variables in C
- Initialization of global and static variables in C
- Static Variables in C
- Difference between Static and Dynamic Memory Allocation in C
- Static functions in C
- Can static functions be virtual in C++?
- Static data members in C++
- When are static objects destroyed?
- C++ | Static Keyword | Question 1
- C++ | Static Keyword | Question 2
- C++ | Static Keyword | Question 4
- C++ | Static Keyword | Question 5
- C++ | Static Keyword | Question 6
- Count the number of objects using Static member function
- Difference between Static and Shared libraries
- “static const” vs “#define” vs “enum”
- How will you show memory representation of C variables?
Improved By : InathiSirayi