The Cyclomatic Complexity of the pseudocode below is “4”.
Read A
Read B
IF A > 0 THEN
IF B = 0 THEN
Print “No values”
ELSE
Print B
IF A > 21 THEN
Print A
ENDIF
ENDIF
ENDIF
How do we count it?
I heard that it’s # of conditions + 1? Do we count those else statements? I’m confused.
EDIT:
Case 2:
What if we have:
IF (x < y)
statment 1
IF (x < z)
statemnt 2
What will be the Cyclomatic complexity? 2? or 3?
No. Main flow + 3 x ‘
If‘s = 4From the wiki: