Writing modular programs using subprograms

Answer the following:
  1. Functions have data types. Why is it that subprograms do not?
  2. Why don't functions require global variables for returning values the way subprograms do?
  3. Subprograms and functions are both used to break down programs into understandable modules with specific tasks. Can you always use either one or are there circumstances in which you must use one or the other?
  4. Which does the better job of isolating a module from the rest of the program, a subroutine or a function? Explain your answer.

    Hint: Could you have written the card dealing program using a function instead of a subprogram? If you had done so, would it have done a better job of isolating the Range module?


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.