Local Variables: Variables that are defined or changed within a function are called local variables. The scope of these variables remains only within the function they are declared in and gets destroyed once the function ends. 2. Global Variables: Variables that are defined outside of a function or have a global scope are termed global variables. The scope of these variables remains throughout the program. The value of such a variable cannot be changed inside a function or else it will throw an error.