1. Which of the following is a local variable?
(A) A variable declared inside a function
(B) A variable declared outside any function
(C) A variable declared with extern
(D) A variable declared with static at global level
2. Which of the following is a global variable?
(A) Declared inside a block
(B) Declared outside all functions
(C) Declared inside a function with static
(D) Declared as extern inside a function
3. What is the default value of a global variable in C++ if not explicitly initialized?
(A) Garbage value
(B) 0
(C) 1
(D) 1
4. Which keyword is used to declare a variable that retains its value across multiple function calls?
(A) global
(B) extern
(C) static
(D) const
5. Which of the following statements about extern variables is true?
(A) They must be defined outside all functions
(B) They are initialized to 0 by default
(C) They allow a variable defined in another file to be accessed
(D) All of the above
6. What is the scope of a variable declared inside a block {}?
(A) Global
(B) Local to the block
(C) Static
(D) External
7. What happens if a static local variable is not initialized explicitly?
(A) It contains a garbage value
(B) It is initialized to 0
(C) Compilation error occurs
(D) It is initialized to -1
8. Which of the following allows a function to access a global variable defined in another file?
(A) local
(B) static
(C) extern
(D) const
9. Which type of variable is shared by all functions in the same file but not visible outside the file?
(A) Local
(B) Global
(C) Extern
(D) Static global
10. Which of the following statements is true about local and global variables with the same name?
(A) Local variable overrides the global variable within its scope
(B) Global variable overrides the local variable
(C) Compiler throws an error
(D) Both variables are inaccessible