Exclusive OR? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Exclusive OR?

Do C# and C++ have an exclusive OR (XOR) operator? So if only A or B is true it evaluates to true, but not if both A and B are true. In that case it evaluates to false.

7th Jan 2017, 9:38 AM
rick schadron
rick schadron - avatar
3 Answers
8th Jan 2017, 2:10 PM
Myk Dowling
Myk Dowling - avatar
0
Yes, thank you for this quick explanation. But does that mean there's no XOR operator? Because in the way you describe 5 logical operators have to be evaluated by the program, where an XOR is 1 single operator.
7th Jan 2017, 9:50 AM
rick schadron
rick schadron - avatar
0
Also slight mistake in your formula: a && !b || !a && b is working better ;-)
7th Jan 2017, 9:52 AM
rick schadron
rick schadron - avatar