Question

Consider the following code: 1. float foo (int a, int b, int c, int d, float...

Consider the following code:
1. float foo (int a, int b, int c, int d, float e) {
2. float e;
3. if (a == 0) {
4. return 0;
5. }
6. int x = 0;
7. if ((a==b) || ((c == d) && bug(a) )) {
8. x=1;
9. }
10. e = 1/x;
11. return e;
12. }


Function bug(a) should return a value of true when passed a value of a=1.
Build:
• a test suite for 100% statement coverage
• a test suite for 100% branch coverage
• a test suite for 100% condition coverage

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Consider the following code: 1. float foo (int a, int b, int c, int d, float...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following in C int main() { float x = 3.14, *p = &x; int...

    Consider the following in C int main() { float x = 3.14, *p = &x; int r, a = 2, b[] = {5, 6, 7}; <more code here> r = Foo(x, p, &a, b) <more code here> } int Foo(float x,float y, int *z, int *w) { <Foo's code goes here> } statement in Foo result (assigned value) modify Foo's AF variables modify main's AF variables statement in Foo result (assigned value) modify Foo's AF variables modify main's AF variables...

  • Q5 (25pts) Consider the code: int foo(int N){ if (N <= 3) return 2; int res1 = 3*foo(N-4); int...

    Q5 (25pts) Consider the code: int foo(int N){ if (N <= 3) return 2; int res1 = 3*foo(N-4); int res2 = foo(N-2); return res1-res2; } a) (6 points) Write the recurrence formula for the time complexity of this function (including the base cases) for N>=0. You do NOT need to solve it. b) (5 points) Draw the tree that shows the function calls performed in order to compute foo(8) (the root will be foo(8) and it will have a child...

  • Question 1 Given the following composite condition (a>=0 && b==3) || c>b Generate a...

    Question 1 Given the following composite condition (a>=0 && b==3) || c>b Generate a set of test cases (just the input values for a, b, and c) that you need to have 100% MC/DC coverage. Question 2 Given the following fragment of code: int tent=0, x=92, num; cout<<"Guess the number :"; cin>>num; while ((tent<5)&&(num!=x)) { tent++; if (num>x) cout<<"Smaller\n"; else if (num cout<<"Bigger\n"; else cout<<”You won!\n” cout<<"Guess the number :"; cin>>num; } (1) Build the corresponding control flow graph. (2)...

  • Consider the following piece of code int adjust = 0; int foo(int factor, function qux) {...

    Consider the following piece of code int adjust = 0; int foo(int factor, function qux) { int offset = bar(factor) + adjust adjust = (qux (offset) + adjust) / 2; return offset; } Which of the names (symbols) are bound at run-time? factor, qux, and offset foo, factor, and qux All the symbols. adjust, factor and offset

  • Convert the following C code into ARM int foo(int a, int b) { int result =...

    Convert the following C code into ARM int foo(int a, int b) { int result = 0; int i; for (i = 20; i <= 30; i++) { if (i == 24) result += 20; else if (i == 27) result = result * 2; else result = result + a + 3*b; } return result; }

  • (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0)...

    (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...

  • Given the following Java code: class C { public int foo(C p) { return 1; }...

    Given the following Java code: class C { public int foo(C p) { return 1; } } class D extends C { public int foo(C p) { return 2; } public int foo(D p) { return 3; } } C p = new C(); C q = new D(); D r = new D(); int i = p.foo(r); int j = q.foo(q); int k = q.foo(r); (Remember that in Java every object is accessed through a pointer and that methods...

  • 2. Consider the following programs (using C's syntax): #include <stdio.h> int a- 1, b-2; int foo...

    2. Consider the following programs (using C's syntax): #include <stdio.h> int a- 1, b-2; int foo (int x) 1 return (x+a); void ba r () { printf("%d, %d\n",a,b); void foobar) } printf("%d, %d\n", a, b) ; int a -4; bar bfoo (b); bar int main)( int b 8; foobar printf ("%d, %d\n", a, b) ; return 0; (a) What does the program print under static scoping? (b) What does the program print under dynamic scoping?

  • Consider the following Java classes: class A{ public int foo () { return 1; } public...

    Consider the following Java classes: class A{ public int foo () { return 1; } public void message () { System.out.println( "A" + foo()); } } class B extends A { public int foo() {return 2; } } class C extends B { public void message () { System.out.println( "C" + foo()); } } (i) What are the outputs of the following code? (ii) What would be the outputs if Java used static dispatching rather than dynamic dispatching? B b...

  • PUT INTO PYTHON CODE #include <stdio.h> #include <float.h> int main(void) { float a = 1; float...

    PUT INTO PYTHON CODE #include <stdio.h> #include <float.h> int main(void) { float a = 1; float b = 0.5; float c = a + b; int bits = 0; while (c != a) { bits = bits + 1; b = b / 2; c = a + b; } printf("%d\n",bits); return 0; }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT