Monday, March 18, 2013
5:04 PM

XOR of Hexadecimals in C program Example

To do XOR in in C the operator used is "^"


#include<stdio.h>
int main()
{
 int x;
 int y;
 int res;
 printf("\n Please enter the value for first number in hex format:");
 scanf("%x",&x); //reading hexadecimal value
 printf("\n Please enter the value for second number in hex format:");
 scanf("%x",&y);
 res=x^y;
 printf("\n The XOR of two numbers is: %x",res);
}

0 comments:

Post a Comment