The modules are described below:
Main Module M0
call input module M1(FLAG) to obtain flag
call processing module M2(FLAG, ARRAY)
call output module M3(ARRAY) to display ARRAY
Input module M1(FLAG)
Prompt user to input a number and store it in FLAG
Process module M2(FLAG, ARRAY)
common variable ARRAY
switch FLAG
case 1: call module M21
case 2: call module M22
Submodule M21
common variable ARRAY
sort up 100 random numbers and store results in ARRAY
Submodule M22
common variable ARRAY
sort down 50 random numbers and store results in ARRAY
Output module M3(ARRAY)
Display output ARRAY
(b) What is the coupling between M0 and M2?
Answer: control coupling because the FLAG is used to control M2, and
stamp coupling because the data structure ARRAY is passed
between M0 and M2. Since control coupling is stronger
the correct answer is control coupling. If the answer is
stamp coupling student gets 0.5 pt.
(c) What is the coupling between M2 and M21?
Answer: common coupling because M2 and M21 share common ARRAY