Points to Remember to Crack Interviews Questions on Static and Global
The memory allocated for static variables is only once i.e all the objects shared by same memory but when it comes to global variables memory is allocated for each and every object.
Static and global variable differ in life and scope. First, let me explain what is life and scope. Life of an object determines whether the object is still in the memory whereas the scope of the object is whether it can access the variable by its name.a) It is possible that object is live, but not visible (not in scope) b)If an object is not alive but in scope (except for dynamically allocated objects where you refer object through pointers).
The global variable has global scope, I mean it can be accessed by any function, from any file, whereas static variable has file scope, it is not possible to access the variable from any other file. This technique is helpful when u want to make, variable accessible to all functions of that file, but not functions of another file.