this is part of the code. Here, I want to compare digits by xor. So it suppose to give "0111" but it gives "111" as result. How can I fix it? So it suppose to give "0111" but it gives "111" as result. How can I fix it?
1 and 1 = 0
1 and 0 = 1
0 and 1 = 1
0 and 0 = 0
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int BinaryRepForDisk1=1101, BinaryRepForDisk2=1010, Disk3=0, xor1, xor2, power=0;
while(BinaryRepForDisk1!=0)
{
xor1=BinaryRepForDisk1%2;
xor2=BinaryRepForDisk2%2;
if(xor1==xor2)
{
Disk3=Disk3+pow(10,power)*0;
power++;
}
else
{
Disk3=Disk3+pow(10,power)*1;
power++;
}
BinaryRepForDisk1=BinaryRepForDisk1/10;
BinaryRepForDisk2=BinaryRepForDisk2/10;
}
printf("%d",Disk3);
system("pause");
return 0;
}