Section 1 Chapter 5 - Subroutines Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Subroutine

A

A block of code which performs a specific task within a program

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

Function

A

A subroutine which returns a single or multiple values

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

Procedure

A

A subroutine that does not return a value

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

Global Variable

A

Variable that can be used anywhere in the program

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

Local Variable

A

Variable that can only be in a subprogram and only exist during the execution of the subprogram

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

Modular Programming

A

A ‘top down’ method of programming in which the problem is broken down into a number of subtasks

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

Advantages of using subroutines (2)

A
  • Splits the program into simpler tasks

- Reduces duplicate code

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

The use of parameters

A

Allows different parts of the program to pass data without the use of global variables

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

Subroutine interface

A

The parts of a subroutine that are in direct contact with the calling program. This consists of the subroutine name, parameters and returned value(s)

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

Why local variables are a good practice

A

If a value is only needed within a subroutine then it is good practice to make it a local variable. This reduces the total number of variables outside the subroutine and makes the program clearer.

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

Difference between global and local variables

A

Global variables can be accessed and changed anywhere in the program whereas local variables can only be accessed or changed inside their subroutine

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