cyclomatic complexity = no of predicate nodes +1
No of predicate nodes = decision making nodes
so for program X , no of predicate nodes = 3 (if, while , if )
cyclomatic complexity of program X = 3+1=4
For program Y, no of predicate nodes = 3 ( node3, node6, node8)
cyclomatic complexity for program Y = 3+ 1=4
For program Z , no of predicate nodes = 6 ( 3 of X followed by 3 of Y)
cyclomatic complexity of Z = 6+1 =7