126k views
4 votes
The scope of a variable declared outside of any function is:

a) Global

b) Local

c) Within that file only

User Anton Krug
by
5.1k points

1 Answer

3 votes

Answer:

a) Global

Step-by-step explanation:

The scope of a variable declared outside of any function is Global.

Let us consider an example:

int g;

int add(int a,int b){

return a+b;

}

int subtract(int a,int b){

return a-b;

}

Here the variable g is defined outside any function and is accessible anywhere within the program. This is a global variable.

Variables defined within each function - a,b on the other hand have a local scope are are visible only within their respective function bodies.

User JosieP
by
4.9k points