Actually in c if you declare mvyar as type int at the beginnnig of your program, that variable is visible throughout all of your code and functions. If you declare a variable inside of a function then that variable is only visible inside that function.
"The lexical scope of an object or function identifier in an external declaration begins at the end of its declarator and persits to the end of the transaltion unit in which it apears. The scope of a parameter of a function definition begins at the start of the block defining the function, and persists through the function; the scope of a parameter in a function declaration ends at the end of the declarator. The scope of an identifier declared at the head of a block begins at the end of its declarator, and persists to the end of the block."
And now for the bread and butter...
"The scope of a structure, union, or enumeration tag, or an enumeration constant, begins at its appearance in a type specifier, and persists to the end of the translation unit(for declarations at the external level) or to the end of the block (for declarations within a function). If an identifier is explicitly declared at the head of a block, including the block constituting a function, andy declaration of the identifier outside the block is suspended until the end of the block" - The C programming Language by: Dennis M.Ritchie (creator of C)
In simple terms all variables decalred outside of a function are visible inside all functions. Variables inside of functions are visible only inside of those functions. If there exists a variable X outside of a function then any varibale X inside of a function has precedence and will be used instead of the outside X.
The quote above of course goes even deeper then that since it deals with header files etc.. but this is not the topic of this discussion.