Sub-programs Flashcards

1
Q

Modularity

A

The concept of breaking a large program or problem down into smaller chunks

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

Subprogram

A

Self-contained section of code that performs a task

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

Difference between procedures and functions

A

Procedures do not return a value. Functions do return a value.

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

Parameter

A

An item that is passed into a function or procedure

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

Argument

A

The value passed into a parameter

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

Benefits of sub programs

A
  • Allows several programmers to work on an individual program at the same time
  • Code is easier to debug, update, modify and understand
  • Can be reused to solve similar problems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Parameter passing by value

A

Value created for a subroutine being called is a copy of the original.
The parameter is held in a separate memory location therefore is only available to that subroutine.
Copy is now a local variable of that subroutine.

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

Parameter passing by reference

A

A pointer that contains the memory address of the original variable is created.
Any change to that value from within the called subroutine will also affect the value of the original variable.

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

Difference between passing by val and ref

A

By ref:
- The location (in memory) of the data is used. Any changes are retained after the procedure or function has been completed.

By val:
- A local copy of the data is use. This is discarded when the subprogram exits.

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