Computer Science, asked by Anonymous, 8 hours ago

PLEASE HELP PLEASEEEE​

Attachments:

Answers

Answered by anindyaadhikari13
9

\textsf{\large{\underline{Solution}:}}

Here is your co‎de. Its written in Java.

public class Main{

   public static void main(String args[]){

       int x=6, y=5;

       System.out.println("Initially:");

       System.out.println("x = "+x);

       System.out.println("y = "+y);

       x=x++-++y+x;

       System.out.println("After evaluating the expression 1:");

       System.out.println("x = "+x);

       System.out.println("y = "+y);

       x=6;

       y=5;

       System.out.println("After Reinitialization:");

       System.out.println("x = "+x);

       System.out.println("y = "+y);

       x=x++ + ++x + --x + x--;

       System.out.println("After evaluating the expression 2:");

       System.out.println("x = "+x);

       System.out.println("y = "+y);

   }

}

\textsf{\large{\underline{Calculations}:}}

Initially:

> x = 6

> y = 5

Evaluating the first expression:

> x = x++ - ++y + x

> x = 6 - ++y + x  [x remains 6, post-increment]

> x = 6 - ++y + x [x becomes 7]

> x = 6 - 6 + x  [y becomes 6, pre-increment]

> x = x

> x = 7

Therefore:

> x = 7

> y = 6

Now, again consider x = 6 and y = 5. Then:

> x = x++ + ++x + --x + x--

> x = 6 + ++x + --x + x --  [x remains 6, post-increment]

> x = 6 + ++x + --x + x --  [x becomes 7]

> x = 6 + 8 + --x + x--  [x becomes 8, pre-increment]

> x = 14 + --x + x--

> x = 14 + 7 + x--  [x becomes 7, pre-decrement]

> x = 21 + x--

> x = 21 + 7  [x remains 7, post-decrement]

> 28

Therefore:

> x = 28

> y = 5

See the attachment for verification.

Attachments:

anindyaadhikari13: Thanks for the brainliest ^_^
Similar questions