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
(a) What is the cohesion of module M2? (pick the highest cohesion category)
Answer: communicational or informational cohesion
because M2 performs actions on the same data
structure so either answer will be correct
It is, of course, also logical/temporal/procedural
cohesion, but you are required to pick highest cohesion category.