For the given program, draw the Control Flow Graph and find its cyclomatic complexity and write all linear independent paths and derive atleast one test case for each path.(5+2+2+1)
1- #include
2- void main()
3- {
4- int a,b,c,flag;
5-printf("enter three sides of a triangle");
6-scanf("%d%d%d",&a,&b,&c);
7- printf(“Side A is : %d”, a);
8- printf(“Side B is : %d”, b);
9- printf(“Side C is : %d”, c);
10-if((a
11- flag=1;
12- else
13- flag=0;
14-if(flag)
15-
16-if((a==b) && (b==c))
17-printf(“equilateral triangle”);
18-else
19-if ((a! =b) && (a!=c) && (b!=c))
20-printf(“scalene”);
21-else
22-printf(“isosceles”);
23-}
24-else
25-printf (“not triangle”);
26-printf (“end of program”);
Answers
Answered by
4
Answer:
Explanation:
Cyclomatic complexity = E - N + 2*P
where,
E = number of edges in the flow graph.
N = number of nodes in the flow graph.
P = number of nodes that have exit points
The Cyclomatic complexity is calculated using the above control flow diagram that shows seven nodes(shapes) and eight edges (lines), hence the cyclomatic complexity is 8 - 7 + 2 = 3
Attachments:
Similar questions