Question

What is the result of evaluating the following expression? ( 1/2 + 3.5) * 2.0 The...

What is the result of evaluating the following expression? ( 1/2 + 3.5) * 2.0
The result is 7
I need explain.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(1/2+3.5)*2.0

First 1/2 implies performing division on two integers so 1/2 will always gives 0 instead of 0.5. Suppose if you need 0.5 either numerator or denominator should be converted to real number ie., float or double

For example if you want to convert either numerator or denominator to float

1/2===>(float)1/2 or 1/(float)2 (type casting)=0.5

so here 1/2 will always be 0

and parenthesis is having highest priority than all other operators so 1/2+3.5 will be evaluated first and result obtained will be multiplied with 2.0

(1/2+3.5)==>(0+3.5)=3.5 (result will be real number)

so 3.5*2.0 = 7 is answer

Add a comment
Know the answer?
Add Answer to:
What is the result of evaluating the following expression? ( 1/2 + 3.5) * 2.0 The...
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