Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the following pseudo-code :

If (A > B) and (C > D) then
    A = A + 1
    B = B + 1
Endif

The cyclomatic complexity of the pseudo-code is

  • A.2
  • B.3
  • C.4
  • D.5

Answer: B

The cyclomatic complexity of a piece of code is the number of decisions plus one. The pseudo-code has a single if statement whose condition is made of two simple conditions joined by 'and', and each simple condition counts as a decision, so there are two predicates and the complexity is 2 + 1 = 3, option (B). Counting only the whole if as one decision would give 2, and the larger values count decisions that are not there.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.