When in doubt, write a program! It's faster and more accurate than research. I did this on Dev C++, but is it a reasonable assumption that it's the same everywhere?
#include <iostream>
using namespace std;
int main ()
{
int a = 8 * 9 % 5;
cout << a << endl;
a = 10 % 3 * 2;
cout << a << endl;
cin.get ();
return 0;
}
Answers are 2 and 2, so it looks like * and % have equal precedence, so left takes precedence over right, as with multiply and divide. Thus you need another choice in your poll. It's one of the reasons I never liked "PEMDAS". If all you remember is the acronym, you always multiply before dividing, which is wrong, and you always add before subtracting, which is also wrong. So I think it's:
PE[MD%][AS]
Operations inside the brackets have the same precedence.
Last edited by VernonDozier; Nov 9th, 2008 at 4:09 am.