Monday 18 March 2013

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);
}

Share This!



No comments:

Post a Comment

Here We Write The Problems we face at different situations and Solutions to those problems.