# Visibility Scope and Lifetime of Variables There are two basic types of scope: [local](/en/docs/basis/variables/local) scope and [global](/en/docs/basis/variables/global) scope. A variable declared outside all functions is located into the global scope. Access to such variables can be done from anywhere in the program.These variables are located in the global pool of memory, so their lifetime coincides with the lifetime of the program. A variable declared inside a block (part of code enclosed in curly brackets) belongs to the local scope. Such a variable is not visible (and therefore not available) outside the block, in which it is declared. The most common case of local declaration is a variable declared within a function. A variable declared locally, is located on the stack, and the lifetime of such a variable is equal to the lifetime of the function. Since the scope of a local variable is the block in which it is declared, it is possible to declare variables with the same name, as those of variables declared in other blocks; as well as of those declared at upper levels, up to the global level. Example: ``` void CalculateLWMA(int rates_total,int prev_calculated,int begin,const double &price[])   {    int        i,limit;    static int weightsum=0;    double     sum=0; //---    if(prev_calculated==0)      {       limit=MA_Period+begin;       //--- set empty value for first limit bars       for(i=0; i