Computer Science, asked by anjalimishra5449, 1 month ago

int i = 11;
i =i++ + ++i
System. out. println(i++ *++i) ​

Answers

Answered by anindyaadhikari13
4

\texttt{\textsf{\large{\underline{Correct C{o}de}:}}}

int i = 11;

i = i++ + ++i;

System.out.println(i++ * ++i);

\texttt{\textsf{\large{\underline{O{u}tput}:}}}

  • The output of the given co‎de is – 624.

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

Given:

> i = 11

On evaluating the given expression:

> i = i++ + ++i

> i = 11 + ++i ['i' remains 11, post-increment]

> i = 11 + ++i ['i' becomes 12]

> i = 11 + 13 ['i' becomes 13, pre-increment]

> i = 24

Now:

i++ * ++i

= 24 * ++i ['i' remains 24, post-increment]

= 24 * ++i ['i' becomes 25]

= 24 * 26 ['i' becomes 26, pre-increment]

= 624

So, the output of the given co‎de is 624.

\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