This document contains 3 coding examples and asks to calculate the cyclomatic complexity for each. The first code has 1 decision point (the IF statement), so its cyclomatic complexity would be 2. The second code has 1 decision point in the outer while loop, so its complexity is 2. The third code has 2 decision points (the IF statements), so its complexity is 3.
This document contains 3 coding examples and asks to calculate the cyclomatic complexity for each. The first code has 1 decision point (the IF statement), so its cyclomatic complexity would be 2. The second code has 1 decision point in the outer while loop, so its complexity is 2. The third code has 2 decision points (the IF statements), so its complexity is 3.
This document contains 3 coding examples and asks to calculate the cyclomatic complexity for each. The first code has 1 decision point (the IF statement), so its cyclomatic complexity would be 2. The second code has 1 decision point in the outer while loop, so its complexity is 2. The third code has 2 decision points (the IF statements), so its complexity is 3.
Department of Computer Applications (NBA Accredited)
(An ISO – 9001: 2015 Certified & ‘A+’ Grade accredited Institution by NAAC)
Assigement-3
1. Calculate cyclomatic complexity for the given code-
IF A = 354 THEN IF B > C THEN A = B ELSE A = C END IF END IF PRINT A
2. Calculate cyclomatic complexity for the given code-
int i, j, k; for (i=0 ; i<=N ; i++) p[i] = 1; for (i=2 ; i<=N ; i++) { k = p[i]; j=1; while (a[p[j-1]] > a[k] { p[j] = p[j-1]; j--; } p[j]=k;
3. Calculate cyclomatic complexity for the given code-
begin int x, y, power; float z; input(x, y); if(y<0) power = -y; else power = y; z=1; while(power!=0) { z=z*x; power=power-1; } if(y<0) z=1/z; output(z); end