Skip to content

Instantly share code, notes, and snippets.

@calvinfroedge
Created February 20, 2012 03:07
Show Gist options
  • Save calvinfroedge/1867505 to your computer and use it in GitHub Desktop.
Save calvinfroedge/1867505 to your computer and use it in GitHub Desktop.
XOR
#include "stdio.h"
int main()
{
int x = 1, y = 2, z = 3;
if(y > z ^ x > y ^ x > 0) printf("%s \n \n", "True!"); //Only one condition is true, statement evaluates to boolean true
if(z > y ^ x > 0) printf("%s \n \n", "Also True!"); //Both conditions are true. Statement evaluates to boolean false and "Also True!" is not printed
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment