Variables and scope (local, global, static, extern) — C++ MCQs

10
Score: 0
Attempted: 0/10
1. Which of the following is a local variable?



2. Which of the following is a global variable?



3. What is the default value of a global variable in C++ if not explicitly initialized?



4. Which keyword is used to declare a variable that retains its value across multiple function calls?



5. Which of the following statements about extern variables is true?



6. What is the scope of a variable declared inside a block {}?



7. What happens if a static local variable is not initialized explicitly?



8. Which of the following allows a function to access a global variable defined in another file?



9. Which type of variable is shared by all functions in the same file but not visible outside the file?



10. Which of the following statements is true about local and global variables with the same name?



Contents Copyrights Reserved By T4Tutorials