 Let's talk about the concept of variable scope in C. We'll investigate it with this program, which is designed more to demonstrate the concept than to do anything particularly useful. At the start of the program, there's something you haven't seen before, declaring a variable outside of the main function. When you do this, the variable scope is global. It's accessible to all the other functions everywhere in the file. Whenever you encounter an opening brace, C opens up a new scope, an area where variables can be declared and accessed. In this scope, we declare variables B, C, and D. These are local to the scope that was opened by the brace. What happens when the program encounters variable A in the if condition? It isn't, and the program goes up one level of scope and finds A at the global level with the value 11. 11 is less than 100, and the opening brace of the if block opens up another scope. And a different variable named B is allocated in that local scope. C will not complain about a duplicate variable name. B is unique in its scope. Now the program evaluates the right-hand side of the assignment. A isn't in the current scope, so we look at the enclosing scope. It's not there either. We go up to the global scope and find variable A with value 11. B is found immediately in the current scope with value 44. Variable C isn't in the current scope. We look up one level and find it with value 33. The right-hand side works out to 88, and it gets stored in D, which is found one level up from our current scope. When the program encounters the closing brace, the current scope is ended, and any variables declared in that scope go away. Later on in the program, when we print variable B, the only one that exists is the one in the current scope. It will print 22. And when we run the program, that's exactly what happens. Another way to think about scope is from the source code view, using rules to find a variable. Look upward to find a variable declaration. Opening braces are a glass roof. You can look up through them. Closing braces are a metal floor. You can't look through them. For example, when looking for variable A here, you look upwards through all the open braces and find it at the global scope. When looking for variable B here, we won't find the one inside the if statement. The metal floor keeps us from seeing it. Instead, we find the variable B that's visible through the glass roof of the open brace. Having local scope for variables and function parameters becomes very advantageous. The parameters x, y, and variable result defined in function mean are in that function's scope. They're local to that function, and nobody else can access them. If I try to access the result variable from main, the metal floors in the functions will block me. The local scope of parameters and variables in a function means I can name them anything I want, and I know there will never be a conflict with declaration. If I try to access the result variable from main, the metal floors in the functions will block me. That means I can name them anything I want, and I know there will never be a conflict with declarations in other functions.