1.Global Variables
Global variables:
Variables can be declared as either local variables which can be used inside the function it has been declared in (more on this in further sections) and global variables which are known
throughout the entire program. Global variables are created by declaring them outside any function. For example:
int max;
main()
{
.....
}
f1()
{
.....
}
The int max can be used in both main and function f1 and any changes made to it will remain consistent for both functions.The understanding of this will become clearer when you have
studied the section on functions but I felt I couldn't complete a section on data types without mentioning global and local variables.
Global variables:
Variables can be declared as either local variables which can be used inside the function it has been declared in (more on this in further sections) and global variables which are known
throughout the entire program. Global variables are created by declaring them outside any function. For example:
int max;
main()
{
.....
}
f1()
{
.....
}
The int max can be used in both main and function f1 and any changes made to it will remain consistent for both functions.The understanding of this will become clearer when you have
studied the section on functions but I felt I couldn't complete a section on data types without mentioning global and local variables.
Comments
Post a Comment