Question

(b) Evaluate the following C++ expressions and show in the boxes under the operators the of evaluation of the corresponding o

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans:

Expression Value
7 / 2 != 6 / 2 && 9 < 3 * 7 0
2 * 3 + 4 / 2 - 6 + 8 % 3 4
abs(4-7) + 3 / 2 * pow(5.0,2) 28

############################################################

Here the Operator Precedence are: * then / then != then < then && resulted to the value 0

(7 / 2 != 6 / 2 && 9 < 3 * 7)

3 * 7 = 21

6 / 2 = 3

7 / 2 = 3

(3 != 3 && 9 < 21) -------------> 3!=3 returns False which is 0 and 9 < 21 returns True which is 1

(0 && 1) = 0

############################################################

(2 * 3 + 4 / 2 - 6 + 8 % 3)

Here the Operator Precedence are: * then / then % then + then - which resulted to the value 4

2 * 3 = 6

4 / 2 = 2

8 % 3 = 2

(6 + 2 - 6 + 2) = 4

############################################################

abs(4-7) + 3 / 2 * pow(5.0,2)

Here the Operator Precedence are: ( ) has the highest presidence, which is abs() and pow() then / then * then + then - which resulted the value 28

(abs(4-7) + ((3 / 2) * pow(5.0,2)))

abs(4 -7) = 3

pow(5.0,2) = 25

(3 / 2) = 1

1 * 25 = 25

3 +25 = 28

Add a comment
Know the answer?
Add Answer to:
(b) Evaluate the following C++ expressions and show in the boxes under the operators the of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT