C | Variable Declaration and Scope | Question 8
Consider the following C program, which variable has the longest scope?
int a; int main() { int b; // .. // .. } int c; |
chevron_right
filter_none
(A) a
(B) b
(C) c
(D) All have same scope
Answer: (A)
Explanation: a is accessible everywhere.
b is limited to main()
c is accessible only after its declaration.
Quiz of this Question
Recommended Posts:
- C | Variable Declaration and Scope | Question 5
- C | Variable Declaration and Scope | Question 4
- C | Variable Declaration and Scope | Question 3
- C | Variable Declaration and Scope | Question 2
- C | Variable Declaration and Scope | Question 1
- C | Variable Declaration and Scope | Question 7
- C | Variable Declaration and Scope | Question 6
- Can we access global variable if there is a local variable with same name?
- Scope rules in C
- What happens when a function is called before its declaration in C?
- Scope Resolution Operator Versus this pointer in C++?
- What is the difference between single quoted and double quoted declaration of char array?
- How to print a variable name in C?
- Variable Length Argument in C
- Why variable name does not start with numbers in C ?



