Variables are simply names used to refer to some location in memory a location
that holds a value with which we are working.
Since C is a low-level programming language, before a C program can utilize
memory to store a variable it must claim the memory needed to store the values for
a variable. This is done by declaring variables. Declaring variables is the way in
which a C program shows the number of variables it needs, what they are going to
be named, and how much memory they will need.
Within the C programming language, when managing and working with variables,
it is important to know the type of variables and the size of these types. All
variables in C are typed. That is, every variable declared must be assigned as a
certain type of variable.
The Programming language C has two main variable types
Local Variables
Global Variables
Local Variables
Local variables scope is confined within the block or function where it is
defined. Local variables must always be defined at the top of a block. When
a local variable is defined - it is not initalised by the system, we must
initalise it ourself. When execution of the block starts the variable is
available, and when the block ends the variable 'dies'.
Global Variables
Global variable is defined at the top of the program file and it can be visible
and modified by any function that may reference it. Global variables are
initalised automatically by the system when we define them. If same
variable name is being used for global and local variable then local variable
takes preference in its scope. But it is not a good practice to use global
variables and local variables with the same name.