Open In App

ISRO | ISRO CS 2014 | Question 4

Like Article
Like
Save
Share
Report

Consider the following pseudo code

while (m < n)
   if (x > y ) and (a < b) then
      a=a+1
      y=y-1
   end if
   m=m+1 
end while 

What is cyclomatic complexity of the above pseudo code?
(A) 2
(B) 3
(C) 4
(D) 5


Answer: (C)

Explanation: Draw the Control Flow Graph (CFG) for given pseudo code:

22

Now, cyclomatic complexity:

= (number of edges) - (number of nodes) + 1 = 8-6+2 = 4
= Total number of regions = 4
= Total number of decision points + 1 = 3+1 = 4 

Note that decision points at a node = (total number of outgoing edges) – 1.

So, option (C) is correct.

Quiz of this Question


Last Updated : 11 May, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads