Reputation: 385
if (k = = 1)
r + = a;
else if (k = = 2)
r + = b;
else if (k = = 3)
r + = c;
else
r + = d;
switch (k) {
case 1:
r + = a;
break;
case 2:
r + = b;
break;
case 3:
r + = c;
break;
default:
r + = d;
break;
}
I am trying to understand whether for both the multiple if statement and the switch case the sample control flow diagram is the below diagram. I am sure that it is true for the switch case but i am unable to draw one for the multiple if statement
Upvotes: 0
Views: 284
Reputation: 8215
The switch statement is nothing but syntactic sugar for the multiple if/else. The control flows are exactly the same. So is the cyclomatic complexity.
Upvotes: 2