Why are we only allowed to declare and define variables in global section?Why not include assignment in global section? Example:
#include
int
We are not allowed to use assignment in file scope because program execution starts from main. Compiler creates _start function which is executed first and then jump to main is made from there. When main returns, control goes back to _start which is having proper exit procedure to terminate program. So anything which is written outside the functions is only meant for the initializations which will be done compile time
Initialization is different from declaration and assignment. When we initialize variable compiler will make such arrangement that when program execution starts, its value will be what we have initialized. But when we declare a variable, it will be having default initial value specified by its scope. Assignment is done at runtime and not at compile time