Question: Task 1: Using the following source code, answer the questions listed below. 1. public int Funi (int x, int k) { 2. int i=0;

 Task 1: Using the following source code, answer the questions listed below. 

Task 1: Using the following source code, answer the questions listed below. 1. public int Funi (int x, int k) { 2. int i=0; 3. int y x+k; 4. do ( 5. if (x/2 < 2) { 6. ky x; 7. } 8. else{ 9. xk2; 10. y = y + x; 11. 12. 13. 14. 15. 16. 17. } 18. kxy: i=i+1; while (ix); if (x < 0 && y < 0) { k-y-x; else{ 19. k = y + x; 20. 21. 22.) } return k; (a) Draw a control flow graph to represent the method Fun!, shown above. Label the nodes (starting with A) and the outgoing edges of the decision boxes appropriately. (b) Using the line labels in the code for method Fun!, identify all the def-use pairs for the variables x, k and y. (c) Identify a set of test cases that satisfies the all-defs criterion, for variables x, k and y in method Funl. Use trace tables to show how the def-use pairs are covered. If you cannot achieve 100% coverage for the all-defs criterion please explain why. (d) Identify a set of test cases that satisfies the all-uses criterion, for variables x, k and y in method Funl. Use trace tables to show how the def-use pairs are covered. If you cannot achieve 100% coverage for the all-uses criterion, please explain why.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer a Heres the control flow graph CFG for the Fun1 method A ... View full answer

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 Programming Questions!