Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Draw CFG (Control Flow Graph) for program 7.5. Enumerate all paths through this program that traverse the loop zero times and once 1 begin 2
Draw CFG (Control Flow Graph) for program 7.5. Enumerate all paths through this program that traverse the loop zero times and once
1 begin 2 int x, Y 3 int product, request: #define exp-1 #define fact-2 #define exit-3 get_request (request); I/ Get user request (one of three possibilities) product=1; // Initialize product IISet up the loop to accept and execute requests 6 7 9 10 while (true) [ 11 Process the "exponentiation" request 12 13 14 15 16 17 End of processing the "exponentiation" if (request== exp); input (x, y); count-y; while (count0) product= product's: count=count-l ; request 18 Process "factorial" request 19 else if (requestfact) 20 21 input (x); count-x while (count >0) product-productcount, count=count-l; 23 24IEnd of processing the "factorial" request. 25 Process "exit" request. 26 elseif (requestexit) 27 output( Thanks for using this program. Bye!"); 28 break;I/ Exit the loop. End of if output(product): I/Output the value of exponential or factorial. 29 get_request (request); l Get user request once again and jump to loop begin 30 31 32 end 1 begin 2 int x, Y 3 int product, request: #define exp-1 #define fact-2 #define exit-3 get_request (request); I/ Get user request (one of three possibilities) product=1; // Initialize product IISet up the loop to accept and execute requests 6 7 9 10 while (true) [ 11 Process the "exponentiation" request 12 13 14 15 16 17 End of processing the "exponentiation" if (request== exp); input (x, y); count-y; while (count0) product= product's: count=count-l ; request 18 Process "factorial" request 19 else if (requestfact) 20 21 input (x); count-x while (count >0) product-productcount, count=count-l; 23 24IEnd of processing the "factorial" request. 25 Process "exit" request. 26 elseif (requestexit) 27 output( Thanks for using this program. Bye!"); 28 break;I/ Exit the loop. End of if output(product): I/Output the value of exponential or factorial. 29 get_request (request); l Get user request once again and jump to loop begin 30 31 32 endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started