SEARCH
You are in browse mode. You must login to use MEMORY

   Log in to start

level: Chapter 4 - Subroutines

Questions and Answers List

level questions: Chapter 4 - Subroutines

QuestionAnswer
What is a subroutine?Parts of a program can also be formulated elsewhere as a subroutine (subprogram), where the control flow • branches there if required (call) and • returns to the place of the call after the subroutine has terminated (return). We use subroutines to • factor out common parts of an algorithm for reuse • structure larger programs in »digestible units« (modules)
What are parameters?Parameters are means to communicate with subroutines: • In the header, formal parameters are defined, which • act like local variables within the subroutine, but are • initialized by an actual parameter (value of an expression) each time the subroutine is called
Method overloadingMethod names can occur multiple times as long as the methods with the same name differ sufficiently by number or data types of the formal parameters:Naming different things (usually methods) with the same name is called overloading.In a method call, the ambiguity (»Which method is meant?«) is resolved based on number and types of the actual parameters.
RiddleRIDDLE IMPLEMENT THESE CHANGES Extend the circle program by adding another for-loop around the circle drawing loop, which runs, e.g., ten times. Starting with a value of, e.g., 0.1, after each circle segment, slightly enlarge the radius.
RiddleRIDDLE IMPLEMENT THE VERSION WITH TRACE