Considering the following code segment:

if(x>y) {

y=x;

}

else if (x == y){

x=1000;

}

else{

y =100;

}

alert ( 'x=' + x + ', y = '+y);

Given x=0 and y=5, what will be displayed?

x=0, y=5

x=0, y=100

x=1000, y=100

x=0, y=0

Respuesta :

Answer:

Hi!

For x=0 y = 5, the correct answer is x=0, y=100.

Explanation:

if(x>y) {   // Values at this point: x=0, y=5.  0>5 -> false.

    y=x;   //not executes this statement.

  }

  else if (x == y){  // Values at this point: x=0, y=5.  0>5 -> false.

       x=1000;   //not executes this statement.

     }

     else{

        y =100;   //executes this statement. Values at this point: x=0, y=100.

     }

alert ( 'x=' + x + ', y = '+y); //executes this statement. x=0, y=100.

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE