Computer Science, asked by Anonymous, 10 months ago

11. Evaluate the following expressions, if the values of the variables are: p = 7, q= 9,
r = 11;
(a) p* (q++ % 4)*(++ r)
(b) (r - - )% 5 + (r ++ /5)*p
(c) p+= (- -p +5)*(p++)*(r/2)
(d) q* = 5 + (- -q)*(q ++) + 10
12. Evaluate the following expressions, if the values of the variables are: int p, w; k = 8,
m = 11, r = 7;
(a) p = m + (-- r + k) + 3*(m ++ )*m
(b) k+= (-- m%5)*(m++ (10+ r ++)
(c) w = k*(m++/3)+ (k+(- -r +r++))
(d) p = (1++%7)+(- -m%5)+ k*(++k - 8)​

Answers

Answered by orio2914
0

Sorry I had also searched for the same question

Answered by vishakasaxenasl
0

Answer:

11. p = 7, q= 9 and r =11(GIVEN)

(a) p* (q++ % 4)*(++ r)

84

(b) (r - - )% 5 + (r ++ /5)*p

Expression Error

(c) p+= (- -p +5)*(p++)*(r/2)

337

(d) q* = 5 + (- -q)*(q ++) + 10

1050

12.  int p, w; k = 8,

m = 11, r = 7; (Given)

(a) p = m + (-- r + k) + 3*(m ++ )*m

421

(b) k+= (-- m%5)*(m++ (10+ r ++)

35

(c) w = k*(m++/3)+ (k+(- -r +r++))

123

(d) p = (1++%7)+(- -m%5)+ k*(++k - 8)​

1017

Explanation:

  • The given expressions are evaluated on the basis of the operator precedence.
  • The below table shows the category of the operators along with the associativity.
  • Once you learn this table, you can easily evaluate any expression on the basis of it.

Postfix () [] -> . ++ - - Left to right

Unary + - ! ~ ++ - - (type)* & sizeof Right to left

Multiplicative * / % Left to right

Additive + - Left to right

Shift << >> Left to right

Relational < <= > >= Left to right

Equality == != Left to right

Bitwise AND & Left to right

Bitwise XOR ^ Left to right

Bitwise OR | Left to right

Logical AND && Left to right

Logical OR || Left to right

Conditional ?: Right to left

Assignment = += -= *= /= %=>>= <<= &= ^= |= Right to left

#SPJ3

Similar questions