Check sibling questions

What do you understand by local and global scope of variables? How can you access a global variable inside the function, if function has a variable with same name.



A global variable is accessible globally ie., it is declared outside any function and it can be accessed from any function in the program. 

A local variable is accessible only in the function where it is declared ie., it is declared inside a function and can be accessed only from that function.

To access a global variable in a function, if the function has a local variable with the same name, we use the global keyword before the variable name.

Are ads bothering you?

CA Maninder Singh's photo - Expert in Practical Accounts, Taxation and Efiling

Made by

CA Maninder Singh

CA Maninder Singh is a Chartered Accountant for the past 12 years. He also provides Accounts Tax GST Training in Delhi, Kerala and online.