Question: 3. Program P2 CFG. a) Identify the basic blocks for the following program P2 written in pseudo-code. b) Draw the control flow graph. Program P2
3. Program P2 CFG.
a) Identify the basic blocks for the following program P2 written in
pseudo-code.
b) Draw the control flow graph.
Program P2
1) integer A, B;
2) input (A);
3) B = 1;
4) while (int i=1; i<=A; i++)
5) {
6) B = B * i;
7) if (B>13)
8) B = B / 2;
9) else
10) B = B * 2;
11) }
12) output (A,B);
13) end;
4. Program P3 CFG.
a) Identify the basic blocks for the following program P3 written in
pseudo-code.
b) Draw the control flow graph.
Program P3
1) integer A, B;
2) input (A);
3) if (A > 7)
4) {
5) B = 1;
6) } // end if A>7
7) else
8) {
9) B = 2;
10) if (A < 2)
11) B = 3;
12) } // end else A7
13) while (int i=1; i<=A; i++)
14) {
15) if (A<4)
16) B = B + 4;
17) else
18) B = B - 5;
19) } // end for loop
20) output (A,B);
21) end;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
