functions Flashcards
A function is identified by?
Parenthesis ().
Prototype? What is the format?
The declarative piece of the function. It is used like a variable declaration and comes before main or inside of it.
void function(int x);
return 0; in the main function does what?
Returns 0 to the operating system of the program to let it know that the program is done executing.
Function call
using the function
Function Definition
The header and body of the function.
Return type?
The type of data that the function returns upon completion
int doStuff()
int is the return type.
Body of function
The bracket enclosed section of the function that actually performs the objective.
What is the difference between parameters and arguments?
Parameter: void function (var1, var2, var3)
Void function?
A function of the form:
void function ();
that doesn’t return anything but rather, it simply performs a task. It can take varying parameter types however.
A function with a return type terminates at _____ a void function terminates _____
when it encounters a return. It requires a return statement
when it reaches the closing brace
Local Variables inside a function ______
Only exist in that function and are lost once the function terminates
What is the rule for the parameters of your prototype? What about the definition?
For the prototype you just need to note what type of parameters you’re using.
For the definition you must note the name of the variable and the type.
Pass by value?
To pass a function a variable to operate with. This variable is a copy of the original and is terminated once it returns to main. Meaning the original value is unchanged in main.
What is the accessibility of local and global variables to functions?
Local variables are only accessible to the functions they are defined in. Local variables can have the same name inside their respective functions.
Global variables are accessible to all functions since they are defined outside all functions.
Static variables? How are they used?
Static variables keep their values from a function through multiple calls to the program.
static int variable;