question |
réponse |
commencer à apprendre
|
|
A subprogram is a piece code that is identified by a name, is given a local reference environment of its own and is able to exchange information with the rest of the code using parameters.
|
|
|
what two fundamental abstraction facilities do Subprograms/Functions provide commencer à apprendre
|
|
Process/control abstraction, Data abstraction
|
|
|
explain Process/control abstraction: commencer à apprendre
|
|
[1] Provides programmers with the ability to hide procedural details[2] Process abstraction allows us to be concerned only with a procedure’s interface[3]E. g given a procedure sort we don’t need to know the body of sort in order to use it.
|
|
|
commencer à apprendre
|
|
Data abstraction: allows the use of sophisticated data types without knowing how such types are implemented. Again, the aims are to separate concerns and to promote reusability and maintainability of programs.
|
|
|
what is a formal parameter commencer à apprendre
|
|
A formal parameter is a dummy variable listed in the function header and used in the function body.
|
|
|
what is an actual parameter commencer à apprendre
|
|
An actual parameter represents a value or address used in the function call statement.
|
|
|
commencer à apprendre
|
|
Functions may exchange info with the rest of the program by a return value or through the use of parameters. s. n value
|
|
|
what are the 2 ways to bind parameters commencer à apprendre
|
|
: by position or by keyword.
|
|
|
explain parameter binding by position commencer à apprendre
|
|
By position: The binding of actual parameters to formal parameters is by their order of appearance: the first actual parameter is bound to the first formal parameter and so forth. x=foo(3, 0); Safe and effective.
|
|
|
eexplain parameter binding by keyword commencer à apprendre
|
|
Keyword: The names of the formal and actual parameters are used Advantage: Parameters can appear in any order, thereby avoiding parameter correspondence errors. Disadvantage: User must know the formal parameters’ names.
|
|
|
what is in(put) mode in referance to Parameter Passing Methods commencer à apprendre
|
|
Formal parameters receive data from the corresponding actual parameters.
|
|
|
what is out(put) mode in referance to Parameter Passing Methods commencer à apprendre
|
|
Formal parameters transmit data to the actual parameters; or
|
|
|
what is inout) mode in referance to Parameter Passing Methods commencer à apprendre
|
|
Formal parameters receive data from the corresponding actual parameters and Formal parameters transmit data to the actual parameters
|
|
|