Is it invalid to define variables and use i/o outside of a function? When I tried compiling this it complains about all lines except the bold declarations: "does not define a type". I have no clue what that means.
Each variable has a scope, and they are valid only in their scope.
A local variable is only valid in the scope it was defined, a global variable is valid in all part of the program.
You are not allowed to have free standing code in the space between functions.
That space is for global variable definitions, and declarations and function definitions and such like.