When a function performs tasks based on a decision, it has _____ A. functional cohesion B. coincidental cohesion C. logical cohesion D. no cohesion

functional cohesion
coincidental cohesion
logical cohesion
no cohesion

The correct answer is: C. logical cohesion.

Cohesion is a measure of how

well the parts of a module belong together. A module with high cohesion has a single, well-defined purpose. A module with low cohesion has multiple, unrelated purposes.

Logical cohesion is a type of cohesion in which the parts of a module are related by a logical relationship. For example, a function that performs tasks based on a decision has logical cohesion because the tasks are all related to the decision.

Functional cohesion is a type of cohesion in which the parts of a module are related by a functional relationship. For example, a function that performs a single task has functional cohesion because the task is the only thing that the function does.

Coincidental cohesion is a type of cohesion in which the parts of a module are related by chance. For example, a function that performs two unrelated tasks has coincidental cohesion because the tasks are not related to each other.

No cohesion is a type of cohesion in which the parts of a module are not related at all. For example, a function that contains a mix of unrelated code has no cohesion because the code is not related to each other.