Hello Everyone ,

I Try many Way,But I'm Unable to find out Cyclomatic Complexity of below C Code

i = 0;
while (i<n-1) do
j = i + 1;
while (j<n) do
if A[i]<A[j] then
swap(A[i], A[j]);
end do;
i=i+1;
end do;

Please Help Me out !!!

This reply may have come too late, but if you draw a graph of the execution of the function will produce 11 edges, 9 nodes and 1 exit point. First we step into a loop (looks like a triangle of nodes in the graph). The middle of the loop provides the starting point for the inner loop. The inner loop's central node forms the start of an if-statement (looks like a diamond in the graph). Plugging these values into the complexity formula, you will get 11 - 9 + (2*1) = 4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.