Question

7. Which test case below can kill the mutant? Mutant: int x = read(); // x...

7. Which test case below can kill the mutant?

Mutant:

int x = read(); // x is the input

x = 2*x;

if (x > 5){

    printf(“%d”, x);

}else{

            print(“%d”, x/2); // Original: print(“%d”, x-2);

}

A. x = 4

B. x = 3

C. x = 2

D. x = 1

Homework Answers

Answer #1

D) x = 1 is the answer.

A mutant is said to be killed, when the test suite is able to detect the changes.

Here we are performing Mutation testing by changing the operator '-' with '/'.

We have to calculate output for both the operators '-' and '/' with four inputs(1,2,3,4). If the outputs are same in both cases, Mutant is not killed.

Let's check this out

O/P using '/' operator O/P using '-' operator

x = 4 8 8 (No change)

x = 3 6 6 (No change)

x = 2 2 2 (No change)

x = 1 1 0 (Change)

Know the answer?
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
Similar Questions
d = int(input('Enter the date: ')) m = int(input('Enter the month: ')) y = int(input('Enter the...
d = int(input('Enter the date: ')) m = int(input('Enter the month: ')) y = int(input('Enter the year: ')) if m<3: m = m + 12 y = y - 1 a = (2*m) + (6*(m+1)/10) b = y + (y/4) + (y/400) - (y/100) c = d + a + b + 1 f = c / 7 if f == 0: print ('Sunday') elif f == 1: print ('Monday') elif f == 2: print ('Tuesday') elif f ==3: print...
Construct a flowchart based on this code and write its equivalent algorithms. #include <stdio.h> int main()...
Construct a flowchart based on this code and write its equivalent algorithms. #include <stdio.h> int main() { int x,y; float result; char ch; //to store operator choice printf("Enter first number: "); scanf("%d",&x); printf("Enter second number: "); scanf("%d",&y); printf("Choose operation to perform (+,-,*,/): "); scanf(" %c",&ch); result=0; switch(ch) { case '+': result=x+y; break; case '-': result=x-y; break; case '*': result=x*y; break; case '/': result=(float)x/(float)y; break; case '%': result=x%y; break; default: printf("Invalid operation.\n"); } printf("Result: %d %c %d = %.2f\n",x,ch,y,result); // Directly...
convert the while loop into for loop x = int(input('Enter initial value: ')) count = 0...
convert the while loop into for loop x = int(input('Enter initial value: ')) count = 0 if(x<1): print('Error') exit() print('Initial value is: ',x,' ',end='') while(x!=1): if(x%2==0): x=x/2 else: x=3*x+1 count+=1 if(x!=1): rint('Next value is: ',int(x),' ',end='') else: print('Final value ',int(x),', ',end='') print('number of operations performed ',int(count),' ',end='') break
3. What will be the value of w after the following section of code executes: int...
3. What will be the value of w after the following section of code executes: int w = 4, q = 3; if (q > 5)       if (w == 7)           w == 3;       else            if (w > 3)               w = 1;            else               w = 0; A.0            B.1              C.2          D.3 4. What will be the value of b after the following section of code executes: int a = 4, b = 0; if (a...
Question Rewrite the following C program using switch-case statement. and give me an output please use...
Question Rewrite the following C program using switch-case statement. and give me an output please use printf and scanf #include<stdio.h> int main(void) {      int semester;           printf("What is your Studying Level (1-8)?> ");      scanf("%d" , &semester);      if(semester == 1 || semester == 2)           printf("Your are a freshman!\n ");      else if(semester == 3 || semester == 4)           printf("Your are sophomore!\n ");      else if(semester == 5 || semester == 6)           printf("Your are...
A.6 ... static int x = 1; int y = x * 2; void t1() {...
A.6 ... static int x = 1; int y = x * 2; void t1() {                 y++;                 cout << "x: " << x << " | y: " << y << endl;                 y += 1;                 x -= -1; } void t2() {                 int* x = &y;                 cout << "x: " << x << " | y: " << y << endl; } void t3() {                 int y = x;                 static int x...
#include <stdio.h> #include <stdlib.h> int main () { int k; int aux; int size = 8;...
#include <stdio.h> #include <stdlib.h> int main () { int k; int aux; int size = 8; int x[8] = {2, 3, 5, 7, 11, 13, 17, 19}; scanf("%d",&k); aux = x[k]; for (int i = k; i < size - 1; i++) x[i] = x[ i + 1]; x[ size - 1] = aux;   for (int i = 0; i < size; i++) printf("%d ", x[i]); } change this program to Write a program to remove an element from an...
Which value of variable a will make variable x equal to 3? Java int x =...
Which value of variable a will make variable x equal to 3? Java int x = 0; if (a > 0)   if (a%4 == 1)      x = x + 5;     else         if (a%3 == 0)            x = x + 4;         else             x = x + 3; else     x = x + 2;
Write a C function to compute the following output (int) based on two input (int) variables:...
Write a C function to compute the following output (int) based on two input (int) variables: output = a*a + b*b - 2*a*b If the value of output is '0', then return -1 instead. Call the C function 4 times from main() with values of 'a' and 'b' as follows and print output values for each case. a = 3, b = 4 a = 1, b = 1 a = -2 b = 3 a = -4 b =...
Below is C code and Python code for an algorithm. C code: void foo( int n,...
Below is C code and Python code for an algorithm. C code: void foo( int n, int A, int B, int C ) { if( n==1 ) { printf("%d to %d\n",A,B); return; } foo( n-1, A, C, B ); printf("%d to %d\n",A,B); foo( n-1, B, C, A ); Python code: def foo(n , A, B, C): if n==1: print A, "to", B return foo(n-1, A, C, B) print A, "to", B foo(n-1, B, C, A) Let Hn be the number...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT