3.3 LOCAL VERSUS GLOBAL VARIABLES
So far we have seen that the information is passed to a function through parameters. It is possible to pass information to functions other than parameters through global variables. The variables declared outside (and above) the function becomes a global variables for such function.
Word global means universal, available everywhere. In programming, it means such variables are available for use in function main() or any other user-defined functions. A variable declared inside any function is called a local variable. Its scope is for that function itself. It does not have existence outside that function. Program 3.3 will help to understand these concepts.
Problem: Write a program to read the marks obtained and calculate ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access