Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The word precedes the name of every function prototype and heading that does not

ID: 3832338 • Letter: T

Question

The word precedes the name of every function prototype and heading that does not return a value back to the calling routine. Pass by indicates that a copy of the actual parameter is placed in the memory location of its corresponding formal parameter. parameters are found in the call to a function. A prototype must give the of its formal parameters and may give their A after a data type in the function heading and in the prototype indicates that the parameter will be passed by reference. Functions that do not return a value are often called in other programming languages. Pass by indicates that the location of an actual parameter, rather than just a copy of its value, is passed to the called function. A call must have the of its actual parameters and must NOT have the of those parameters. A call must have the of those parameters. refers to the region of a program where a variable is "active." parameters are found in the function heading. In C++ all functions have scope. A function returning a value should never use pass by parameters Every function that begins with a data type in the heading, rather than the word void, must have a (n) statement somewhere, usually at the end, in its body of instructions. In C++ a block boundary is defined with a pair of

Explanation / Answer

1) void
explanation: When we declare function type as 'void' it means the function is not going to return any value to the caller.


2) copy
explanation: Pass by copy and Pass by reference are two techniques used to send parameters to the function called. In pass by copy only the values are copied to formal parameters from actual parameter. So even if the formal parameters are modified there is no change in actual parameters outside the function. Whereas for pass by reference address is passed because of that the change in formal parameters is visible outside of the function.


3) actual
explanation: In functions parametes can be categorized into actual and formal parameters. Actual parameters are parameters as they appear in function calls. Formal parameters are parameters as they appear in function declarations.


4)
a) number
b) type
c) parameter names
explanation: A function prototype is actually called as signature where we mention the function declaration without its body. Here we indicate the type and number of parameters function can except along with function return type. The parameter names can be provided but it is optional


5) &(ampersand)
explanation: '&'' after the data type and before the variable name in function heading indicates the parameters will be passed by reference


6) void
explanation: Functions that do not return a value are called void functions because they will not pass any value back to the caller


7) reference
explanation: Pass by reference is a technique where instead of value the addres of variable is passed so it can be modified inside the function and changes are reflected outside of it.


8)
a) same number
b) same type
explanation: It is very important that the number and types of actual parameters passed match with the number and types of parameters expected by the functions formal parameter list. If the number of arguments matches but the data types do not, then the compiler MAY insert some type conversion code if the correct data types are known, but it is safer not to rely on this.


9) Scope
explanation: Scope of a variable is a region of source code, where you can refer to that variable whereas "lifetime" is the how long it exists during program execution. By default lifetime of a local variable is same as its scope.


10) Formal
explanation: Formal parameters are written in function prototype and function header. Formal parameters are local variables which are assigned values from the arguments when the function is called.


11) Function scope
explanation: In c++ the variables declared in the outermost block of a function have function scope. They can be accessed only in the function that declares them. Also labels (of goto) have function scope that is they cannot be used outside the function.


12) reference
explanation: A function returning a value should never use pass by reference parameters. Because when values are passed by reference to the calling function any modifications inside the function will be reflected outside of the function. Hence pass by reference values need not be returned to the caller.


13) return
explanation: In function prototype when we specify return type other than void. The function body is expected to have a return statement usually at end of the function body.


14) curly braces { and }
explanation: In c++ a block boundary is defined within a pair of curly braces. That way a variable scope can be defined properly based on its storage type.