The primary difference is that the declaration of a local variable occurs inside a function while that of a global variable occurs outside of it. Due to this, we lose the local variables once the function in which we executed it terminates. But the global variable stays intact, and we only lose them once the execution of the entire program terminates.