Computer Science, asked by sxaxa1974, 2 months ago

if x=5, find the value of y; y=(5*++x)%6; y=x*++x;​

Answers

Answered by anindyaadhikari13
3

Answer:

Given,

\tt >> x = 5

We have to find the value of y.

\tt >> y = (5 *++ x)\%6

As x becomes 6, pre-increment,

\tt >> y = (5*6)\%6

\tt >> y = 30\%6

30 divided by 6 leaves remainder 0.

\tt >> y = 0

\tt >> x = 6

Now,

\tt  >> y = x* ++ x

\tt  >> y = 6*7 \: (pre - increment)

\tt  >> y = 42

 \therefore \ \boxed{\begin{cases} \tt x = 7 & \\ \tt \: y = 42\end{cases}} \tt  \:  \: (Answer)

Learn More:

  • Prefix Operator: When increment or decrement operator is used before the operand, it is called prefix operator. In this case, the value of the operand is first incremented or decremented and then operation is carried out.
  • Postfix Operator: When increment or decrement operator is used after the operand, it is called postfix operator. In this case, the operation is first carried out and then the value of the operand is incremented or decremented.

•••♪

Similar questions