Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

calculate the cyclomatic complexity: calculate the cyclomatic complexity. 1) int

ID: 3782896 • Letter: C

Question

calculate the cyclomatic complexity:

calculate the cyclomatic complexity.

1)    integer A, B;

2)    input (A);

3)

4)    if (A > 7)

5)    {

6)   B = 1;

7)    }

8)    else

9)    {

10)   B = 2;

11)   if (A < 2)

12)   B = 3;

13)    } // end else !A>7

14)

15)    while (i=1; i<=A; i++)

16)    {

17)    if (B<0)

18)    {

19)    B = B + 4;

20)    }

21)    else

22)    {

23)    B = B - 5;

24)    } // end else !B<0

25)    } // end loop

26)

27)        output (A,B);

28) end;

Start false true true 3 false true V false true alse End

Explanation / Answer

Answer:

We have the formulla for the Cyclomatic Complexity as : -

M = E N + 2P

Where E is the number of edges , N is the number of nodes and P is the number of connected components.

Here in this problem , E = 15 , N = 11 , P = 1

Therefore , M = E N + 2P

=> M = 15 -11 - 2*1

=> M = 4 -2 = 2

=> M = 2 is the cyclomatic complexity.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote