Examine the differences between local and global variables in terms of scope and lifetime.