Understand the difference between local and global variables and how scope determines their visibility.
Scope is a fundamental concept in C that defines the region of the program where a variable is accessible. Understanding scope rules is essential for managing data and avoiding naming conflicts, especially in larger programs. There are two main types of scope: local and global. **Local variables** are declared inside a function or a block (a set of statements enclosed in curly braces `{}`). Their scope is limited to that function or block. This means a local variable is only 'visible' and can only be used within the block where it was declared. It is created when the program enters the block and is destroyed when the program exits the block. Different functions can have local variables with the same name without causing any conflict, as they exist in separate scopes. This is a key principle of encapsulation and helps make functions self-contained. **Global variables** are declared outside of all functions, typically at the top of the source file. Their scope extends from the point of declaration to the end of the file, meaning they can be accessed and modified by any function within that file. While global variables can be convenient for sharing data between functions, their use is generally discouraged. Because they can be modified from anywhere, they make the program harder to debug and reason about. It becomes difficult to track which function is changing the variable's value, leading to potential bugs and tight coupling between functions. It's usually better practice to pass data between functions using parameters and return values rather than relying on global variables.