Exam 3 Flashcards
(55 cards)
Why do local variable lose their values between calls to the function in which they are defined?
Local variables lose their values to transfer the value
What is the difference between an argument and a parameter variable?
An argument is values that are sent into a function and a parameter is a variable that holds a value being passed into a function.
Where do you define parameter variables?
Define the parameter variable after the void statement in the parantheses
If you are writing a function that accepts an argument and you want to make sure the function cannot change the value of the argument, what do you do?
Declare the function as a const
When a function accepts multiple arguments, does it matter what order the arguments are passed?
Yes, when the function is written it expects each parameter to be of a certain type in a certain order.
How do you return a value of a function?
Return y
What is the advantage of breaking your applications code into several small procedures?
There are small, simpler functions so it’s easy to maintain and understand.
How would a static local variable be useful?
Can refer to local static variable outside of the function
Give an example where passing an argument by reference would be useful
To modify the value of the function arguemnts and to avoid making copies of an object for performance reasons
The _ is the part of a function definition that shows the function name, return type, and parameter list.
Header
If a function doesn’t return a value, the word _ will appear as it’s return type.
Void
Either a functions _ or it’s _ must precede all calls to the function
Definition, prototype
Values that are sent into a function are called
Arguments
Special variables that hold copies of function argument are called _
Parameters
When only a copy of an argument is passed to a function, it is said to be passed by
Value
A(n) _ eliminates the need to place a function definition before all calls to the function
Prototype
A _ variable is defined inside a function that is not accessible outside the function
Local
_ variables are defined outside all functions and are accessible to any function within their scope
Global
Unless you explicitly initialize global variables, they are automatically initialized to
Zero
If a function had a local variable with the same name as a global variable, only the _ variable can be seen THE by the function
Local
_ local variables retain ther value between function calls
static
The _ statement causes a function to end immediately
return
_ arguments are passed to parameters automatically if no argument is provided in the function call
default
When a function uses a mixture of parameters with and without default arguments, the parameters with default arguemnts must be define _
last