in IS&Software Engineering retagged by
7,960 views
6 votes
6 votes

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?

  1. 2
  2. 3
  3. 4
  4. 5
in IS&Software Engineering retagged by
8.0k views

4 Comments

8 - 6 + 2 = 4

0
0
Thank u i got it
1
1

@Satbir

Any idea about the equivalent C code?

0
0

3 Answers

14 votes
14 votes
Best answer

Cyclomatic complexity will be 8 - 6 +2 = 4

selected by
by

4 Comments

edited by

Before seeing this question- answer, I still believe there is only one way to escape the loop (without break condition or OS preemption) i.e the falsity of loop condition check , Can anyone please explain me how this edge (?) is opened here, Since official ans is also 4 , but I am getting 3 with my approach.

Thanks in advance !!!

 

0
0

@dr_Jackal Even I'm getting 3 as answer. This solution is clearly wrong. There won't be any edge between last to nodes. Also last node won't be "end while". "end while" must be in last second node. Here they gave just "if'-then" statement not "if-then-else" statement. So in the diagram there is an extra node. 

0
0
This seems to be a favorite question of ISRO.
1
1
10 votes
10 votes

Answer is (B) part.

1 comment

which answer is right ... 3 or 4 ?
0
0
5 votes
5 votes

Cyclomatic complexity = no of predicate nodes +1

=3+1

One for while,  two for if bcoz of two conditions as if first condition then if second condition then do given. 

2 Comments

Can you draw the control flow graph.
0
0

\

check that

1
1
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true