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);
}
#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);
}
No comments:
Post a Comment