Functions and Procedures Flashcards

(4 cards)

1
Q

What is a procedure?

A

A sequence of steps that performs a task but does not return a value to the caller

Identified by a name and called to execute a specific sub-task.

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

What is a function?

A

Similar to a procedure but designed to return a value to the caller after executing its sub-task

Functions are essential for operations requiring output.

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

What does it mean to pass parameters by value?

A

The actual value of a variable is passed to the function or procedure, and a copy is made

The original variable remains unchanged.

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

What does it mean to pass parameters by reference?

A

The address (reference) of the variable is passed, allowing the function or procedure to modify the original variable

This enables direct manipulation of the variable’s value.

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