Computer Science, asked by soumiliray94, 1 month ago

if a=8 find the value of a= a++ + ++a

please answer fast​

Answers

Answered by anindyaadhikari13
4

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

  • The final value of a is - 18.

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

Given:

> a = 8

On evaluating the expression:

> a = a++ + ++a

> a = 8 + ++a   [a remains same, post-increment]

> a = 8 + ++a   [a becomes 9]

> a = 8 + 10    [a becomes 10, pre-increment]

> a = 18

⊕ Hence, the final value of a is 18.n

\texttt{\textsf{\large{\underline{Learn 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


anindyaadhikari13: Thanks for the brainliest!
Similar questions