Multiple choice

Which of the following statements is correct?

  1. Local variables are declared inside a function and accessible within the function only.

  2. Global variables are declared in a separate file and accessible from any program.

  3. Global variables are declared inside a function and accessible from anywhere in the program.

  4. Local variables are declared in the main body only and accessible from functions only.

  5. Global variables are declared inside a function and accessible inside the function only.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Local variables are C program variables and hold scope inside a function only. Global variables hold scope for an entire program.