Topic 4 subroutines

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/22

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

23 Terms

1
New cards

What is a subroutine?

a set of instructions with a name

2
New cards

What is a function?

A subroutine that returns one or more values using the return keyworrkf

3
New cards

What is a prodecure?

does not return a value

4
New cards

What are built-in functions

built in functions that perform complex task

5
New cards

What is the module library?

•libraries of pre-defined subroutines

6
New cards

What are the arguments in parentheses used for?

•Arguments in parentheses are used to pass data to a subroutine

7
New cards

Where do parameters appear?

in subroutine definitions

8
New cards

Where do arguments appear?

in subroutine calls

9
New cards

What are local variables

variables that were declared inside a program

10
New cards

What are global variables

variables declared in the main program. They are not indented

11
New cards

What does pass by value mean?

•that the actual value of the argument in the calling statement is copied to the variable parameter in the subroutine

12
New cards

What does pass by reference mean?

the address of the argument in the calling statement is passed to the corresponding parameter in the subroutine

13
New cards

What is the difference between functions and procedures

a function can return the value of the variable whilst a procedure does not have a return function

14
New cards

Why do we try to make the subroutines to only complete one task

makes the code reusable by anyone

15
New cards

What is a variable scope

•When a variable is in scope
the values can be accessed

16
New cards

What is a global variable?

•is defined in the main program and can be used in any subroutine called from the main program

17
New cards

What is a local variable?

•A local variable can be used only in that subroutine

18
New cards

What is the scope of a local variable ?

is the subroutine in which it is declared in

19
New cards

what are the advantages of local variables?

the subroutine is independent of a particular program and can be re used in different programs

no chance of accidentally changing a variable

20
New cards

What is modular programming?

breaking down a major task into smaller sub tasks and doing so until each ‘module’ performs a single function

21
New cards

What are the advantages of modular programming?

•Programs are more easily and quickly written

•Large programs are broken down into sub tasks that are easier to program and manage

•Each module can be individually tested

•Modules can be re-used several times in a program

•Large programs are much easier to debug and maintain

22
New cards
23
New cards