^ is known as " Bitwise Exclusive OR Operator " .
The bitwise exclusive OR operator (^) compares each bit of its first operand to the corresponding bit of its second operand.
If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
p = 2 = 0010
q = 5 = 0101
pq means = 0010 ^ 0101 = 0111 = 4+2+1 = 7
qp means = 0101 ^ 0111 ( because now p is changed to 0111) = 0010 = 2
Hence output is 7,2 which is option D .