Computer Science, asked by deeksha912, 1 year ago

If x = 3 initially, what will be the result 'x' after the execution of the following statement:. x + = x + + + - - x + 4;​

Answers

Answered by Sumanmi
11

x+=3(4) + 3 +4

x+= 10

x=3+10

x=13

Answered by nain31
24
 \mathcal{GIVEN}

 \mathsf{x = 3}

 \mathsf{x + = x ++ + --x + 4}

Here x++ is a increment postfix operator .This will change or will increase the value of x by 1 after exceution of program. Here the value of x will increase after x++.
So it will become 4.

Here --x is a prefix decrement operator. This will change or will decrease the value of x by 1 before execution of programming.

Here x+ is short hand binary operator .It can be formed only when a variable is used as an counter in the expression. The same variable is to be used both after and before the assignment sign.

So,

 \mathsf{x + = x ++ + --x + 4}

 \mathsf{x = x+ x ++ + --x + 4}

 \mathsf{x = 3 +3 + 3 + 4}

 \boxed{\mathsf{x = 13}}

Shruthi123456: Nice answer didi
Anonymous: awesome answer ma'am :)
nain31: ma'am?
nain31: thank bro and sis❤
Anonymous: welcome.. xD... mera sapna poora Ho gya xD
Shruthi123456: You're welcome Naina didi❤
Similar questions