samedi 29 février 2020

Cyclomatic Complexity of multiple if statements

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

Control flow grpah

Aucun commentaire:

Enregistrer un commentaire