Question: For each of the source code fragments below 1) construct a DEF_USE table listing all the line numbers where a variable is defined or used.


For each of the source code fragments below 1) construct a DEF_USE table listing all the line numbers where a variable is defined or used. You must list all the variables in each source code fragment 2) construct a DU Path table showing all paths from any definition to usage of every variable. A sample example is given below. Example 1 maino 2 { 3 int numi, 4 num2 5 answer; 6 printf ("nThis program finds the product or sum of two numbers"); 7 printf (" 'n What is your first number?'); 8 scanf("%d", &numl); 9 printf(" 'n What is your second number?''); 10 scanf(%d", &num2); 11 if (numi >num2) 12 answer = num1*num2; 13 else 14 answer = numi+num2; 15 printf(" Your first number was %10d", numl); 16 printf (" Your second number was %10d", num2); 17 printf (" The product is %10d, answer); 18 } DEF-USE Table DU Path Table Variable DEF USE Variable # DU Path numi 11, 12, 14, 15 numi 1 8-9-10-11 num2 4.10 11, 12, 14, 16 2 8-9-10-11-12 5, 12, 14 17 3 8-9-10-11-14 8-9-10-11-12-15 num2 10-11 2 10-11-12 3 10-11-14 4 10-11-12-15-16 1 12-15-16-17 2 14-15-16-17 3,8 answer 4 1 answer Problem 1 Problem 2 int x; int y; intz; 1 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
