Computer Science, asked by prosnehal7, 2 months ago

If x= 6 initially what will be the result/output of the
following two expressions?
(i) 10 * + + x;
(ii) X ++ * 10;​

Answers

Answered by tksharma1508
2

ANSWER

(a) 5* ++x;

30

WORKING

   5* ++x

⇒ 5* 6       [∵ ++x will first increment x to 6 and then use it in the expression]

⇒ 30

(b) 5* x++;

25

WORKING

   5* x++

⇒ 5* 5       [∵ x++ will first use the current value of x in the expression which is 5. After that x is incremented to 6]

⇒ 25

Answered by BrainlyProgrammer
5

Answer with Explaination:-

Given, x=6

Output of:-

  • 10 * ++x

10 * ++x

here ++x is prefix increment operator so x will first increase the value

10 * ++6

10 * 7

70

  • x++ * 10​

Now here, it is x++ and x++ is postfix increment operator

Therefore, it will first calculate then increase its value

6 * 10

60

\dag\tt{\large{\bold{Note}:\begin{cases}\sf{ ++x\:and\:--x\:are\:prefix\:increment/decrement\:operator}\\\sf{x++\:and\:x--\:are\:postfix\:increment/decrement\:operator}\\\sf{Postfix\:operator\:increases\:its\:value\:after\:moving\:forward}\\\sf{Prefix\:operator\:increases\:its\:value\:before\:moving\:forward}\end{cases}}}

Similar questions