Order of Precedence

Hello, I am in a C++ class and I am having an issue with trying to manually compute a expression within the guidelines of order of precedence. I am mainly having an issue with using the modulus operator on xp's calculator. How do I use the "%" modulus operator on the calculator?

Here is a couple of expressions that I am having problem with:

26-14 % 3 + 1

The answer is 24

3 + 16 / 7 % 2

The answer is 3.0

Thank you for your help!!!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Calv1n,
When ever there is a question of precedence, I recommend you use () to wrap around objects you want associated together.  Most programmers don't keep the complete order of precedence memorized, and even if you did, any one maintaining your code would probably have trouble predicting the out come of your code.

You can try something like the following method:
= (26-14) % (3 + 1);

David Maisonave :-)
Jaime OlivaresSoftware ArchitectCommented:
modulus has the same precedence as division
How do I use the "%" modulus operator on the calculator?
do you mean electronic calculator?
if you want to do 14 % 3 in a calculator.
you can do like this 14 divide by 3 you will get answer like 4.6666667 (let's say a.bbbbbbb)
then you minus whatever is a then you multiply back 3 then you can get the modulus value which is 2.

Is this what you want?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
>26-14 % 3 + 1
The answer is 25, not 24.
What was the guy asking and what he really wanted to ask...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.