Reputation: 87
want to apply OR operation between two numbers, but showing the above error , hence am unable to understand what might be the problem!
#include <iostream>
using namespace std;
int main(){
unsigned char a,b;
cin>>a>>b; //input two number
cout << a | b; //applying bitwise OR operation
}
Upvotes: 0
Views: 798
Reputation: 5565
<<
has higher operator precedence than |
, so by default it interprets cout << a | b;
as though you'd written (cout << a) | b;
. To get what you want, rewrite your expression as cout << (a | b);
.
Upvotes: 1
Reputation: 549
You just need to write the expression in parentheses .
cout << (a | b);
Upvotes: 0