Consider three software items: Program-X, Control Flow Diagram of Program-Y and Control Flow Diagram of Program-Z as shown below Program-X: Control Flow Diagram of Program-Y sumcal (int maxint, int value) {       int result=0, i=0;       if (value <0)       {           Value = -value;       }       while ( (i

Consider three software items: Program-X, Control Flow Diagram of Program-Y and Control Flow Diagram of Program-Z as shown below Program-X: Control Flow Diagram of Program-Y sumcal (int maxint, int value) {       int result=0, i=0;       if (value <0)       {           Value = -value;       }       while ( (i<value) AND (result <= maxint) )       {           i=i+1;         result = result + 1;       }       if (result <= maxint)       {            print (result) ;       }       else       {            Printf(“large”);        }        printf(“end of program”); } Control Flow Diagram of Program-Z   The values of McCabe’s Cyclomatic complexity of Program-X, Program-Y, and Program-Z respectively are Correct Answer 4, 4, 7

Concept:

Cyclomatic complexity is a source code complexity measurement that is being correlated to a number of coding errors.

Formula:

Cyclomatic complexity = e – n + 2p

Where, e = number of edges

n = number of nodes

p = number of nodes that have exit points

Also, cyclomatic complexity = number of predicates + 1

Or, cyclomatic complexity = number of regions

Explanation:

Program X contains three predicates i.e. three conditional statement i.e. 3

So, cylomatic complexity = 3 + 1 = 4

Program Y:  this contains 4 regions.

So, cyclomatic complexity = 4

Program Z: Program Z contains both X and Y. Combining both, it contains 6 predicates .

So, cyclomatic complexity = 6 + 1 = 7

Related Questions

Determine output:
#include void main(){ char *p = NULL; char *q = 0; if(p) printf(" p "); else printf("nullp"); if(q) printf("q"); else printf(" nullq");}
Comment on the following 2 C programs.
#include  //Program 1int main(){ int a; int b; int c;}#include  //Program 2int main(){ int a; { int b; } { int c; }}
Comment on the output of the following C code.
#include int main(){ int a = 1; switch (a) case 1: printf("%d", a); case 2: printf("%d", a); case 3: printf("%d", a); default: printf("%d", a);}