Computer Science, asked by aishini7, 1 month ago

plz Solve this above question ...plz donot give unnecessary answers if u don't know ....​

Attachments:

Answers

Answered by anindyaadhikari13
3

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

  • The final value of 'a' is 7.
  • The final value of 'b' is 1.
  • The final value of 'c' is 14.

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

Given:

> a = 5

> b = 3

> c = 0

On evaluating the given expression:

> c = ++a + a++ + b-- - --b

> c = 6 + a++ + b-- - --b  [a becomes 6, pre-increment]

> c = 6 + 6 + b-- - --b  [a remains 6, post-increment]

> c = 12 + b-- - --b  [a becomes 7]

> c = 12 + 3 - --b  [b remains 3, post-decrement]

> c = 15 - --b  [b becomes 2]

> c = 15 - 1  [b becomes 1, pre-decrement]

> c = 14

Therefore:

\sf\implies\begin{cases}\sf a=7\\ \sf b= 1\\ \sf c=14\end{cases}

\texttt{\textsf{\large{\underline{Know More}:}}}

There are two types of increment/decrement operations.

  1. Post increment/decrement.
  2. Pre increment/decrement.

Post Increment/Decrement: Here, operation takes place first and then the value is incremented/decremented.

Example:

> int a = 2;

> int b = a++;

> b = 2

Now, a = 3.

Pre Increment/Decrement: Here, value is first increment/decrement and then the operation is carried out.

Example:

> int a = 2;

> int b = ++a;

> b = 3

Also, a = 3

Similar questions