2.2 Flashcards

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

2.2.1
1. What is modularity?
2. What are the different names for modules?

A
  1. Modularity is the concept of breaking a large program or problem down into smaller chunks. The goal is to design a program so that each module carries out a single, specific task.
  2. The different names for modules are: subroutines, procedures, functions and methods.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

2.2.1
1. What is a procedure?
2. What is a function?

A
  1. A procedure is a block of code that takes in zero, one or more parameters and performs a set task, but does not return a value.
  2. A function is a block of code that takes in zero, one or more parameters, performs a set task, and returns a value. The return value from a function does not need to be assigned to a variable, as long as it returns a valid item.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

2.2.1
1. What is the outline of a subroutine?
2. What are the two methods for passing data into a subroutine?

A
  1. The first line of a subroutine specifies the interface for that subroutine. Depending on the programming language, the layout of a subroutine is slightly different, but the basic outline is: the name of the subroutine, the list of parameters it requires when it is called, the order of those parameters, and the data type for those parameters, and if it is a function, then it also includes a return value.
  2. The two methods for passing data into a subroutine are: passing by value, passing by reference.
    Passing by value means the variable used is a local variable self-contained within the function. Passing by reference means editing the global variable in the program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly