If you are new to programming you should know that the compiling always starts at the main function. Any code outside the main function is called "unreachable code" unless it is called by the main function.
For example you can have another function outside the main function(with new variables) but it will not be executed unless you call for it in the main() function.
Variables always needs to be inside a function or they will be unreachable.
The only exception I know to this rule is Constants. You can assign a constant using #define, before the main() function but not after the main(). For example:
#define LENGTH 100
#define WIDTH 50
void main()
{
}
I hope this helps.