Page 1 of 1

For each of the four problems below: 1. Draw the program graph. You must use line numbers to label all nodes in the grap

Posted: Mon Jul 11, 2022 9:57 am
by answerhappygod
For each of the four problems below: 1. Draw the program graph.You must use line numbers to label all nodes in the graph. Do notuse the statements or statement fragments themselves as labels. 2.Compute the cyclomatic number using each of the three methodsdiscussed in the lectures. Show your work. 3. Calculate P* usingthe given conditions for each problem. Show your work.
1.
Problem a:
void Q1() {S1;if ( C1 && C2 && C3 ) {S2;}else if (C4) {S3;if (C5) {S4;else {S5;}}else {S6;}S7;}
Problem b:
void Q2() {S1;if ( C1 ) {for (S2; C2; S3) {if ( C3 && C4 ) {S4;}else {S5;}}}else {if ( C5 && C6 ) {S6;If ( C7 ) {S7;}}else {S8;}}S9;}
For P*, assume that the for loop (line 4) executes exactly 4times.
Problem c:
void Q2() {S1;if ( C1 && C2 ) {S2;}else {for ( S3; C3; S4 ) {S5;if (C4) {S6;}}}if (C5) {for ( S7; C6; S8 ) {S9;}}else {S10;}S11; }
For P*, assume that the for loop (Line 7) may be executedanywhere from 0 to 4 times, the for loop (Line 15) is executedexactly 2 times.
Problem d:
void Q4 () {S1;while (C1) {if ( C2 && C3 ) {S2;}else if ( C4 && C5 ) {S3;}else {S4;}while (C6 && C7) {S5;if (C8) {S6;}else {while (C9) {S7;}}}S8;}}
For P*, assume that the while loops (Lines 3, 13 and 19) areexecuted exactly 3, 2, and 3 timesrespectively.