Global scope varible

the code which is explained by the lecturer is confusing she is explaining the code without using new program
in the same program she is explaining it which is creating more doubts the clearing aslo she has not explained about the heap memory

At this point of time you are studying functions, if I keep creating a new file for every new function then it destroys the entire purpose of studying functions.

Various types of memory are part of Operating System, may be you can refer to first chapter of Galvin.