Question

Consider the variables x, y and z where x and y are int variables initialized to...

Consider the variables x, y and z where x and y are int variables initialized to 10 and 0 respectively, and z is a double variable initialized to 6.5

What values are stored in each variable after each statement executes? Keep in mind that the statements execute in sequence. x y z

y = x++ + 5;

z -= ++y * x--;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE: The output may vary in different compilers.

y = x ++ + 5;

This statement is executed from right to left.

Hence, y = 11 + 5 = 16 and x = 11

z -= ++y * x--;

Again, this statement is executed from right to left.

Hence, z = z - ++y * x-- = 6.5 - 16 * 11

As per BODMAS, multiplication has higher priority and is performed first.

Hence, z = 6.5 - 176 = -169.5

Add a comment
Know the answer?
Add Answer to:
Consider the variables x, y and z where x and y are int variables initialized to...
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
  • Suppose x, y, and z are int variables and w and t are double variables. What...

    Suppose x, y, and z are int variables and w and t are double variables. What value is assigned to each of these variables after the last statement executes? a) x = 17; b) y = 15; c) x = x + y / 4; d) z = x % 3 + 4; e) w = 17 / 3 + 6.5; f) t = x / 4.0 + 15 % 4 - 3.5;

  • Can someone help with this multiple choice question for C++ Suppose that x and y are...

    Can someone help with this multiple choice question for C++ Suppose that x and y are int variables, z is a double variable, and the input is: 28 32.6 12 Choose the values of x, y, and z after the following statement executes: cin >> x >> y >> z; a. x = 28, y = 12, z = 32.6 b. x = 28, y = 12, z = 0.6 c. x = 28, y = 32, z = 12.0...

  • Assume x and y are boolean variables that were declared and initialized correctly. Regardless of the...

    Assume x and y are boolean variables that were declared and initialized correctly. Regardless of the initial values for x and y, which Java statement is logically equivalent to all of the Java source code below? boolean z = false; if (!x) N = true; else if (x && Y) Z = true; = !x || Y; N = x || ! (x && y); N z !X && (x && y); = !x && Y; N none of the...

  • Save Submit Assignmer e Questic Check M Suppose that x, y, z, and w are int...

    Save Submit Assignmer e Questic Check M Suppose that x, y, z, and w are int variables. What is st ored in x y z, and w after the follow ng statements execute? (3-6) Submit your answer to dropbot x=9 y=x-4; ws(x * z) / y-3; Browse.

  • QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x,...

    QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x, int& y); int Doughnut(int y, int z); int main( ) {             int a = 1;             int b = 2;             int c = 3;             int d = 4;             Pancake(a, b, c);             Waffle(b, c);             Pancake(d, c, b);             d = Doughnut(b, a);             return 0; } void Pancake(int x, int& y, int z) {             y += 3;            ...

  • A) Consider the expression where z and y are real variables that defines on the range (x > 0) and...

    a) Consider the expression where z and y are real variables that defines on the range (x > 0) and (y) (i) Rearrange the expression in (A) to the following form (Clearly show each step of your work a42 2r+4 MATHCAD (ii) This part of question requires you to use Mathcad worksheet 'Graphs and Differentiation' associated with Unit 1, to obtain a graph of y(x) against a for the range 0< 10. Submit one page of Mathcad printout, which indicates...

  • Three variables x, y, and z defined as unsigned char, short, and int types in C...

    Three variables x, y, and z defined as unsigned char, short, and int types in C Programming. What are the maximum values they can take? Compare the following C programs. After execution of this short programs what will be the value of x if printed in function? void foo(void); int main(void){             foo();             foo();             foo(); return 0; } void foo() {             int x = 1;             x++;               } void foo(void); int main(void){             foo();             foo();...

  • Can someone explain how the answer is 2. thanks 0.2/0.2 pts Question 2 Read the program and the descriptions below #include <stdio.h> int x=0x10, y=0x200, z=0x30; int main) int a, b-0x12, c-0x20...

    Can someone explain how the answer is 2. thanks 0.2/0.2 pts Question 2 Read the program and the descriptions below #include <stdio.h> int x=0x10, y=0x200, z=0x30; int main) int a, b-0x12, c-0x20, d-0x210; a0x5; while (c <- y) printf("END In") Assume that (i) rG represents the register pointing to the beginning of the locations where the global variables are stored, (ii) rL denotes the register that records the start of the locations where the local variables are stored, and (iii)...

  • 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...

  • the inorder order of x y z is y x z Consider the rotations in the...

    the inorder order of x y z is y x z Consider the rotations in the insertion and the removal of AVL trees. Let w be the position to insert or to remove one node. Let z be the first unbalanced node along the path from w to the root. Let y he z's child with larger height and x he y's child with larger height. Consider the case where the in order order of x. y. z is y,...

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