Our next topic is scope rules. Scope rules involve declarations. The declarations typically occur at the head of blocks, and blocks can exist in different architectures. There can be nested blocks and there can be parallel blocks. We'll see parallel blocks later. Now inside those blocks we're going to have nomenclature, we're going to have identifier names and identifier names can be for both functions and for variables. What we have to know about them is when they're available, what their lifetime is. The first thing we're going to look at is something we've already used and that's basically a simple arrangement. So here for example is something fairly simple. Int main void block or we declare i, we initialize it to five. Now its lifetime begins. So it exists and we can use it throughout this code. Then we can enter an inner block and we can declare further variables. For example, you can say int j is assigned i plus two. So if I had remained five now j is seven. At this point we could print both i and j. We would get five and seven. Now if we exit this inner block, j lifetime goes away, j disappears. We see while for simple variables that isn't critical, other variables that involve large amounts of storage like very big arrays, this can become critical and it can be a cause of efficiency of the use of resources, that is the memory resources. So it becomes important in large-scale programs. Then once again we're outside this inner block. Here if we printf of i we can do it, we can get five again. But what we couldn't do is if we tried to printf of j it no longer exists and we get a syntax error. More complex situation. Here's an outer block, i is five. We're allowed to declare an inner block variable of the same name. But what that's going to do is it's going to hide the outer block variable. So the innermost block and this could go on, we could have them even further nested. This is now thought of as i outer, this is i inner. Anytime there's a reference in here like if we did a printf here, we would see seven and three not five and three. So there isn't a way to look at the outer block. There is by the way possibilities of doing that in C++ but not in C. So once you reuse a name, the preference for a name is in whatever is most local, whatever block is most local. Once you get out of here, the outer i is no longer hidden, it can be used, j disappears, the inner i disappears, your lifetime goes away. We have structures that are nested outer and we've inner. Inside here we have lifetimes, they go away. Inside here we have lifetimes and then it goes away. We also have an architecture that's parallel. So if we call that Block 1 and parallel with Block 2, we have a lifetime for these variables that goes from here to here. Then we have a new set of variables that goes from here to here. Different lifetimes and of course there are different lifetimes where we're declaring functions as well. When we invoke a function, we have a lifetime and it only exists as long as the function Is being executed. Keep this in mind, when this set of variables is declared, it's put on something called stack. It's that internal way that the compiler manages storage for these variables. Later we'll see a different way to manage storage which will be heap based. But for the moment, the way we will always managed storage is all related to these blocks and the declarations of things within this blocks.