Question

What is the result of the following expression 30 + 10.0 * 5 - 50 %...

What is the result of the following expression

30 + 10.0 * 5 - 50 % 5

in C++ please

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

In C++, for arithmetic operator *, /, % have higher precedence than +, - And they are evaluated from left to right.

Here, 30 + 10.0 * 5 - 50 % 5

So first 10.0*5 will be evaluated. 10.0*5 = 50.0

Now, the expression has become: 30 + 50.0 - 50 % 5

Then, 50%5 will be evaluated. 50%5 = 0

Now, the expression has become: 30 + 50.0 - 0

Then, 30 + 50.0 will be evaluated. 30 + 50.0 = 80

Now, the expression has become: 80 - 0

So, finally, 80 - 0 will be evaluated. 80 - 0 = 80

Therefore, reuslt = 80

Add a comment
Know the answer?
Add Answer to:
What is the result of the following expression 30 + 10.0 * 5 - 50 %...
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