Computer Science, asked by shlokrkhairnar, 1 month ago

If x=4, find the value of: x=x++ + ++x + 7

Answers

Answered by anindyaadhikari13
5

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

Given:

> x = 4

On evaluating the given expression, we get:

> x = x++ + ++x + 7

> x = 4 + ++x + 7   [x remains 4, pre-increment]

> x = 4 + ++x + 7   [x becomes 5]

> x = 4 + 6 + 7  [x becomes 6, pre-increment]

> x = 17

Therefore:

\rm:\longmapsto x=17\ \ (Answer)

\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