Computer Science, asked by ss2007ind, 1 day ago

If a=5 Find - a++ + ++a + a++​

Answers

Answered by anindyaadhikari13
5

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

  • The final value of a is 19.

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

The initial value of 'a' is 5.

After evaluating the expression,

> a = a++ + ++a + a++

> a = 5 + ++a + a++  [a remains 5, post-increment]

> a = 5 + ++a + a++  [a becomes 6]

> a = 5 + 7 + a++  [a becomes 7, pre-increment]

> a = 12 + a++

> a = 12 + 7  [a becomes 8 after post-increment]

> a = 19

⊕ So, result obtained = 19.

\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

Answered by dass70652
2

Answer:

Answer : a = 3

Explanation:

I hope it's helpful

Similar questions