+ 5

Operator priority order in C++?

Dear all, I don't know Why result of method 1 is 0? (Method 2: OK) Thanks! // #1: #include <iostream> using namespace std; int main() { cout<<0||1&&1; return 0; } Output: 0 // #2: #include <iostream> using namespace std; int main() { cout<<(0||1&&1); return 0; } Output: 1

21st Jan 2019, 5:22 AM
Nguyễn Văn Sơn
Nguyễn Văn Sơn - avatar
2 Antworten
+ 2
Priority of operators is as follows:- NOT(!, ~) AND (&&) OR(||)
13th Feb 2019, 3:01 AM
Mayank Mewar
Mayank Mewar - avatar