Computer Science, asked by powersantuk1017, 4 days ago

Int w=5, t=9; t++; t=++w + t++

Answers

Answered by Anonymous
1

Answer:

The \texttt{++} operator increases an integer variable by 1. It can only be used with integers. \texttt{++x} increments \tt{x} before anything. \texttt{x++} increments \tt{x} after statement.

\texttt{++x} and \texttt{x++} both add 1 to \tt{i}. However, \texttt{++x} returns the new value, and \texttt{x++} returns the old value.

We have been given \tt{w = 5} and \tt{t = 9}, and we have been asked to find out the value of \tt{t=++w + t++}.

\tt{\implies t = ++w + t++}

\tt{\implies t = ++5 + 9++}

\tt{\implies t = 6 + 10}

\therefore \; \boxed{\tt{t = 16}}

Hence, the value/output of t is 16.

\rule{100mm}{2pt}

Notes:

  • The \texttt{++} and \texttt{--} can only be used with Integers.
  • These operators can also be used as postfixes like \tt{n++} and \tt{n--}.
Similar questions