Question: Consider the following program fragments. For each program fragment, draw a flow graph, identify the independent paths, and, for each path, give examples of inputs

Consider the following program fragments. For each program fragment, draw a flow graph, identify the independent paths, and, for each path, give examples of inputs that would cause the path to be executed.

(a) z= readNumber(); y =readNumber();

x = 1;

j = 1;

while (y>= j) {

j = j + 1;

x = x * z;

}

writeNumber(x);

(b) x = readNumber();

y = readNumber();

while (x != y) {

if (x > y) {

x = x -y; }

else

{ y = y -x;}

}

writeNumber(x);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!