Quizzes and Extra Credit for Week 4.
Post your answers to the Quizzes from Week 4 here rather than in the chapter thread, so as not to spoil things for the others.Chapter 5 Quiz 1. Where do global functions exist? Where do member functions exist? 2. What is a function? 3. When a function identifier is encountered, where does execution jump to? Where does it return to after the function terminates? 4. How do you declare a function’s return value type? 5. What is a parameter list? 6. Can you use a function before it has been declared? Can you use it before it has been defined? 7. If a function has been defined before being used, must I provide a separate function declaration (prototype)? 8. Is it wise to use definitions throughout your code in place of declarations? Why or why not? 9. Is it necessary that a function prototype and definition agree EXACTLY about return type and signature? 10. Must a function prototype includes the names of variables in the parameter list? 11. Must the parameter names in the declaration (prototype) match the parameter names in the definition? 12. What do we call variables created within the scope of a block? 13. What happens to those variables when the function returns to a higher scope? 14. [Extra Credit] Are these variables created on the stack, or the heap? 15. By default, are parameter variables local or global? What does this mean for the value of the variable after the function returns? 16. What do we call the default passing method which implies the creation of temporary variables? 17. What is a global variable? Where can it be accessed? 18. What happens to global variables when there is a local variable with the same name? 19. Why are global variables dangerous? 20. [Extra Credit] How short or long (how many lines) should a function be? (yes, there is a correct, but tricky answer) 21. What can be passed as input to a function? What is the only requirement? 22. How do you return a value from within a function? 23. What is a “default value” for a parameter value? Where is it specified? What does it look like? 24. Is this a valid prototype? What does it mean? “int MyIntFunction( int = 10, int = 20 );” 25. What is function overloading? What benefit does it provide? 26. What is recursion? When is it useful?