1. Local scope:
A variable declared inside a block can be used only in the block. It cannot be used any other block.
Eg: int sum(int n1,int n2)
{
int s;
s=n1+n2;
return(s);
}
Here the variable s is declared inside the function sum and has local scope;
2. Global scope:
A variable declared outside of all blocks can be used anywhere in the program.
Eg:
int s;
intsum(int n1,int n2)
{
s=n1+n2;
return(s);
}
Here the variable s is declared out side of all functions and we can use variable s any where in the program.