Subroutines Flashcards

1
Q

Define subroutines

A

Subroutines are a way of managing and organising programs in a structured way. This allows us to break up programs into smaller chunks.

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

What is the difference between a procedure and a subroutine

A

Subroutines that do not return values and do not have to have input parameters are called procedures.
Subroutines that allow us to have both input and output are called functions.

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

What is a global variable?

A

A global variable is a variable that can be used anywhere in a program. The issue with global variables is that one part of the code may inadvertently modify the value because global variables are hard to track.

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

What is a local variable?

A

A local variable is a variable that can only be accessed within a certain block of code typically within a function. Local variables are simple not recognized outside a function unless they are returned. There is no way of modifying or changing the behavior of a local variable outside its scope.

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