Global variables are those which can be used in global space i.e, accessible to any functions in a particular file or class. But local variables are limited to the scope of a function only. They lost their value after coming out of function.
Let’s see how to create a global variable and local variables and how to use them.
Next, we will see how to access the local variables.
Here, we will see how the global variable will be modified inside the function.
Hope you understood the concepts of local and global variables. There are many cases when local and global comes into the picture. So, it is important to keep this concept in mind.
Stay tuned! Keep Learning with us.