What is the problem with the last two statements in the code?
#include <iostream>
using namespace std;
int main()
{
cout << "2 + 4 = " << 2 + 4 << endl;
cout << "2 * 4 = " << 2 * 4 << endl;
cout << "2 | 4 = " << 2 | 4 << endl;
cout << "2 & 4 = " << 2 & 4 << endl;
What should I do to fix this?
Operator precedence.
|and&have lower precedence than<<, socout << "2 & 4 = " << 2 & 4 << endl;gets parsed as(cout << "2 & 4 = " << 2) & (4 << endl;).Put parens around
2 | 4and2 & 4.