Parameter Passing Flashcards

1
Q

Describes how values are passed to a function

A

Parameter Passing

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

Types of Parameter Passing (2)

A
  1. Pass by Value
  2. Pass by Reference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The formal parameter contains a copy of the value of the actual parameter.

Only the value is being passed.

A

Pass by Value

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

The address of a variable is being passed to the function.

The formal parameter points to the actual parameter.

The matching formal parameter is a pointer.

A

Pass by Reference

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

When to use pass by value?

A
  1. When you are NOT changing the actual parameter
  2. When you are returning ONLY ONE value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When to use Pass by Reference?

A
  1. When you need to change the value of the actual parameter
  2. When you need to modify two or more values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly