Computer Science, asked by cocobunnyplay, 1 month ago

find the output of this​

Attachments:

Answers

Answered by anindyaadhikari13
7

\texttt{\textsf{\large{\underline{Answer}:}}}

  • The output of the given co‎de is – 130, 19, 9

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

Given:

> x = 12

> y = 22

On evaluating the expression:

> z = --x % --y * x - y--/x-- % y + y-- - x--

> z = 11 % --y * x - y--/x-- % y + y-- - x-- (x becomes 11, pre-decrement)

> z = 11 % 21 * x - y--/x-- % y + y-- - x-- (y becomes 21, pre-decrement)

> z = 11 * x - y--/x-- % y + y-- - x--

> z = 11 * 11 - y--/x-- % y + y-- - x--

> z = 121 - 21/x-- % y + y-- - x-- (y remains 21, post-decrement)

> z = 121 - 21/x-- % y + y-- - x-- (y becomes 20)

> z = 121 - 21/11 % y + y-- - x-- (x remains 11, post-decrement)

> z = 121 - 1 % 20 + y-- - x-- (x becomes 10)

> z = 121 - 1 + y-- - x--

> z = 120 + y-- - x--

> z = 120 + 20 - x-- (y remains 20, post-decrement)

> z = 140 - x-- (y becomes 19)

> z = 140 - 10 (x remains 10, post-decrement)

> z = 130 (x becomes 9)

Therefore:

 \sf \implies \begin{cases} \sf x = 9 \\ \sf y = 19 \\ \sf z = 130 \end{cases}

So, the output for the given code is:

>> 130, 19, 9

Note: While solving this kind of problems, you have to know the operator precedence table so as to evaluate the expression.


anindyaadhikari13: Thanks for the brainliest :)
Similar questions