Question

Suppose x and y are variables, consider the following statement: if ( x > 5 )...

Suppose x and y are variables, consider the following statement:

if ( x > 5 )

y = 1;

else if ( x < 5 )

{

if ( x < 3 )

  y = 2;

else

y = 3;

}

else

   y = 4;

What is the value of y if x = 6?

Homework Answers

Answer #1

Answer:

y = 1

Given code snippet:

if ( x > 5 )

y = 1;

else if ( x < 5 )

{

if ( x < 3 )

  y = 2;

else

y = 3;

}

else

   y = 4;

The above code snippet is about the if-else condition.

The if-else statement is used to perform operations depends on the specific conditions. The operations in if block will execute if and only if the given condition is satisfied. Otherwise else conditions will execute.

Here if the condition is :

if ( x > 5 )

As the given value is 6, if the condition satisfied. So the compiler won't consider remaining else statements.

The operation in if block is ; y = 1;

So y=1

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
Consider joint Probability distribution of two random variables X and Y given as following f(x,y)   X...
Consider joint Probability distribution of two random variables X and Y given as following f(x,y)   X        2   4   6 Y   1   0.1   0.15   0.06    3   0.17   0.1   0.18    5   0.04   0.07   0.13 (a)   Find expected value of g(X,Y) = XY2 (b)   Find Covariance of Cov(x,y)
The following table show the data on three variables X, Y and Z X 6 5...
The following table show the data on three variables X, Y and Z X 6 5 3 5 7 Y 1 2 3 4 3 Z 2 3 2 3 2 Given that X is a function of Y and Z, find the multiple regression equation, hence find the value of X when Y and Z are 5 and 4, respectively.
The following table show the data on three variables X, Y and Z X 6 5...
The following table show the data on three variables X, Y and Z X 6 5 3 5 7 Y 1 2 3 4 3 Z 2 3 2 3 2 Given that X is a function of Y and Z, find the multiple regression equation, hence find the value of X when Y and Z are 5 and 4, respectively.
1. Suppose that x, y, z, and w are int variables. What is stored in x,...
1. Suppose that x, y, z, and w are int variables. What is stored in x, y, z, and w after the following statements execute? (3, 6) x = 9; y = x - 4; z = (y + 7) % 6; w = (x * z) / y - 3; z = w + (x - y + 2) % x)
Consider the following joint distribution between random variables X and Y: Y=0 Y=1 Y=2 X=0 P(X=0,...
Consider the following joint distribution between random variables X and Y: Y=0 Y=1 Y=2 X=0 P(X=0, Y=0) = 5/20 P(X=0, Y=1) =3/20 P(X=0, Y=2) = 1/20 X=1 P(X=1, Y=0) = 3/20 P(X=1, Y=1) = 4/20 P(X=1, Y=2) = 4/20 Further, E[X] = 0.55, E[Y] = 0.85, Var[X] = 0.2475 and Var[Y] = 0.6275. a. (6 points) Find the covariance between X and Y. b. (6 points) Find E[X | Y = 0]. c. (6 points) Are X and Y independent?...
Consider the following data set consisting of two variables: x 0 3 5 6 8 y...
Consider the following data set consisting of two variables: x 0 3 5 6 8 y 10 9 7 4 1 (a) Draw a scatter diagram of the data. (b) Compute the correlation coecient r. (c) Is there a linear relation between x and y that you are condent about? If so, in what direction? Justify your answer.
3. Consider the statement ∀x ∈ Z ∃y ∈ Z : (x 6= y) ∧ (x|y)....
3. Consider the statement ∀x ∈ Z ∃y ∈ Z : (x 6= y) ∧ (x|y). (a) Negate this statement. The statement you obtain may not contain the symbol ¬. (b) Write the original statement in English without using any symbols or variables! (c) Is the original statement true? Prove your answer.
Given are five observations for two variables, x and y. xi 1 2 3 4 5...
Given are five observations for two variables, x and y. xi 1 2 3 4 5 yi 4 6 6 11 15 Which of the following scatter diagrams accurately represents the data? 1. 2. 3. What does the scatter diagram indicate about the relationship between the two variables? Develop the estimated regression equation by computing the the slope and the y intercept of the estimated regression line (to 1 decimal). ŷ = + x Use the estimated regression equation to...
Consider independent random variables X and Y , such that X has mean 2 and standard...
Consider independent random variables X and Y , such that X has mean 2 and standard deviation 4, and Y has mean 1 and standard deviation 9. Find the mean and standard deviation of the following random variables. a) 3X b) Y + 6 c) X + Y d) X − Y e) X1 + X2, where X1, X2 are independent copies of X.
Suppose X and Y are independent variables with E(X) = E(Y ) = θ, Var(X) =...
Suppose X and Y are independent variables with E(X) = E(Y ) = θ, Var(X) = 2 and Var(Y ) = 4. The two estimators for θ, W1 = 1/2 X + 1/2 Y and W2 = 3/4 X + 1/4 Y . (1) Are W1 and W2 unbiased? (2) Which estimator is more efficient (smaller variance)?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT