GATE | GATE-IT-2004 | Question 69

Consider the following program module:

int module1 (int x, int y) {
    while (x! = y) {
        if (x > y)
             x = x - y,
        else y = y - x;
        }
    return x;
}

What is Cyclomatic complexity of the above module?
(A) 1
(B) 2
(C) 3
(D) 4


Answer: (C)

Explanation: Condition nodes :

1.While

2. if

Cyclomatic Complexity=2+1=3

 

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.