Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribed

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 2 main 3 { 4 float price 5 float benefit: 6 float discount; 7 printf("inputprice:"); 8 scanf("%f",&price); 9 if(price>=10000.0) 10 { 11 discount=0.1*price; 12 benefit=0.05*(price-discount); 13 price=10000; 14 } 15 if(price"benefit>=5000.0) 16 { 17 discount=0.05*price; 18 benefit=0.03*(price-discount); 19 price=5000; 20 } 21 if(prices=1000.00) 22 { 23 benefit=0.02* (price-1000); 24 } 25 printf("the benefit=$.3f", benefit); 26 printf("the price=$.3f",price); 27 ) 1 void main 2 { 3 4 5 6 int t; 7 scanf("%d%d%d",&x.&y.&z); 8 if (x >y+z) { 9 t+= x 10 x=y+4; 11 z=y+x; 12 } 13 if (x == z) { 14 x=t-4; 15 y=2; 16 z=0; 17 } 18 if(y * z != 0) { 19 t=y* z; 20 y=t; 21 } 22 printf("That is: %d %d %d ",x,y,z); 23 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions