Functions Flashcards

1
Q

advantages of using functions

A

code isnt duplicated
we can reuse common utilities
problems can be broken up into sub problems
unit testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

general layout for a function header

A
>return type< >function name< ()
{
  function body
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how to separate parameters in function lsit

A

using commas`

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

which are the functions ttat everyone can see

A

public`

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

3 things that can be sent into a function

A

call by value parameters
call by reference parameters
member data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

3 things that are returned from a function

A

member data
return type
call by reference parameter`

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

why shouldnt you use parameters as local varibales in functions

A

because this will change the value of that parameter outside the function which may not be your intention

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

can local variables in one function be acessed by code in another functoin

A

no, unless the variables are constants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

variables that are defined in the parameter list are in scope until

A

The function ends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is recursion

A

the calling of a function within the function itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly