Photo by Fabian Irsara on Unsplash
Understanding the scope of variables in C programming
Global and local variables
Variables are containers that hold up assigned values to them. These values can be character, number , date, boolean etc. Variables in C are first declared before they are used. Declaring means telling the compiler about what is going to be stored in that container. So you have to tell the compiler the following.
- datatype of the variable
- size of the variable
- name of the variable
accessing stored variable.
After variable being allocated memory in the system we may want to access these variables for use in our program.