Cyclomatic complexity{if((x=0) or (y=0))p=0;else{p=x;i=1;while(i!=y){p=p+x;i=i+1;}}}

Showing Answers 1 - 7 of 7 Answers

Amit Dhamija

  • Aug 15th, 2005
 

ans. 2

  Was this answer useful?  Yes

chaitanya

  • Nov 9th, 2006
 

How the answer is 2. Since there are 3 independent paths if u c if am not wrong.

  Was this answer useful?  Yes

abhi_dendrite

  • Dec 6th, 2006
 

The program begins with a conditional statement if (x==0) ||( y==0)...therefore it gives rise to 2 paths

Lets take a dry run...

lets say a) x=1,y=0; b) x=0 & y=0; c) x=0,y=1; d) x=1,y=1

condition a returns true

condition b returns true

condition c returns true

condition d returns false

Therefore there are actually 2 possibilities hence 2 paths two individual paths for the code..There cannot be any other possibility..

Also if we do a flowchart E=2; N=2 and cyclomatic complexity E-N+2=2

If I am wrong please enlighten me abhi_dendrite

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions