What is the scope of local and global variables in C.
Scope of local variables
- Local variables can only be accessed by other statements or expressions in same scope.
- Local variables are not known outside of their function of declaration or block of code.
Scope of global variables
- Global variables can be accessed form anywhere in a program. The scope of the global variables are global throughout the program.
- Any function can access and modify value of global variables.
- Global variables retains their value throughout the execution of entire program.
What are the uses of main function in C.
- Execution of any C program starts from main function.
- The main function is compulsory for any C program.
- C program terminates when execution of main function ends.